melonjs 15.3.0 → 15.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  5. package/dist/melonjs.mjs/application/application.js +53 -5
  6. package/dist/melonjs.mjs/application/header.js +2 -2
  7. package/dist/melonjs.mjs/application/resize.js +4 -8
  8. package/dist/melonjs.mjs/application/settings.js +5 -5
  9. package/dist/melonjs.mjs/audio/audio.js +4 -6
  10. package/dist/melonjs.mjs/camera/camera2d.js +12 -14
  11. package/dist/melonjs.mjs/const.js +1 -1
  12. package/dist/melonjs.mjs/entity/entity.js +3 -4
  13. package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
  14. package/dist/melonjs.mjs/geometries/line.js +18 -25
  15. package/dist/melonjs.mjs/geometries/path2d.js +16 -13
  16. package/dist/melonjs.mjs/geometries/point.js +8 -16
  17. package/dist/melonjs.mjs/geometries/poly.js +40 -97
  18. package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
  19. package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
  20. package/dist/melonjs.mjs/index.js +6 -6
  21. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  22. package/dist/melonjs.mjs/input/input.js +1 -1
  23. package/dist/melonjs.mjs/input/keyboard.js +3 -3
  24. package/dist/melonjs.mjs/input/pointer.js +4 -4
  25. package/dist/melonjs.mjs/input/pointerevent.js +6 -7
  26. package/dist/melonjs.mjs/lang/console.js +1 -1
  27. package/dist/melonjs.mjs/lang/deprecated.js +2 -2
  28. package/dist/melonjs.mjs/level/level.js +1 -1
  29. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  30. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
  31. package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
  32. package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
  33. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
  34. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
  35. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
  36. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +26 -29
  37. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
  43. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  44. package/dist/melonjs.mjs/loader/cache.js +1 -1
  45. package/dist/melonjs.mjs/loader/loader.js +1 -1
  46. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  47. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  48. package/dist/melonjs.mjs/loader/parser.js +4 -5
  49. package/dist/melonjs.mjs/loader/settings.js +1 -1
  50. package/dist/melonjs.mjs/math/color.js +2 -2
  51. package/dist/melonjs.mjs/math/math.js +1 -1
  52. package/dist/melonjs.mjs/math/matrix2.js +5 -59
  53. package/dist/melonjs.mjs/math/matrix3.js +82 -141
  54. package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
  55. package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
  56. package/dist/melonjs.mjs/math/vector2.js +7 -91
  57. package/dist/melonjs.mjs/math/vector3.js +6 -90
  58. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  64. package/dist/melonjs.mjs/particles/emitter.js +2 -2
  65. package/dist/melonjs.mjs/particles/particle.js +2 -2
  66. package/dist/melonjs.mjs/particles/settings.js +1 -1
  67. package/dist/melonjs.mjs/physics/body.js +22 -20
  68. package/dist/melonjs.mjs/physics/bounds.js +27 -33
  69. package/dist/melonjs.mjs/physics/collision.js +5 -5
  70. package/dist/melonjs.mjs/physics/detector.js +10 -10
  71. package/dist/melonjs.mjs/physics/quadtree.js +5 -5
  72. package/dist/melonjs.mjs/physics/response.js +1 -1
  73. package/dist/melonjs.mjs/physics/sat.js +3 -4
  74. package/dist/melonjs.mjs/physics/world.js +6 -9
  75. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  76. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  77. package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
  78. package/dist/melonjs.mjs/renderable/container.js +25 -25
  79. package/dist/melonjs.mjs/renderable/draggable.js +1 -1
  80. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  81. package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
  82. package/dist/melonjs.mjs/renderable/light2d.js +3 -3
  83. package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
  84. package/dist/melonjs.mjs/renderable/renderable.js +26 -26
  85. package/dist/melonjs.mjs/renderable/sprite.js +3 -3
  86. package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
  87. package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
  88. package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
  89. package/dist/melonjs.mjs/renderable/text/text.js +422 -0
  90. package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
  91. package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
  92. package/dist/melonjs.mjs/renderable/trigger.js +10 -10
  93. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
  94. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
  95. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
  96. package/dist/melonjs.mjs/state/stage.js +2 -2
  97. package/dist/melonjs.mjs/state/state.js +1 -38
  98. package/dist/melonjs.mjs/system/device.js +49 -10
  99. package/dist/melonjs.mjs/system/dom.js +1 -1
  100. package/dist/melonjs.mjs/system/event.js +24 -2
  101. package/dist/melonjs.mjs/system/platform.js +18 -18
  102. package/dist/melonjs.mjs/system/pooling.js +10 -10
  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 +1 -1
  106. package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
  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 +2 -2
  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 +2 -3
  118. package/dist/melonjs.mjs/utils/string.js +1 -1
  119. package/dist/melonjs.mjs/utils/utils.js +1 -1
  120. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +3 -7
  121. package/dist/melonjs.mjs/video/renderer.js +16 -16
  122. package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
  123. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  124. package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
  125. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  126. package/dist/melonjs.mjs/video/video.js +4 -4
  127. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
  128. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
  129. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
  130. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
  131. package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
  132. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
  138. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  139. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  141. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +50 -52
  142. package/dist/melonjs.module.js +1137 -1576
  143. package/dist/types/application/application.d.ts +28 -4
  144. package/dist/types/application/header.d.ts +2 -2
  145. package/dist/types/application/settings.d.ts +23 -23
  146. package/dist/types/audio/audio.d.ts +3 -5
  147. package/dist/types/camera/camera2d.d.ts +13 -16
  148. package/dist/types/entity/entity.d.ts +0 -1
  149. package/dist/types/geometries/ellipse.d.ts +18 -50
  150. package/dist/types/geometries/path2d.d.ts +1 -1
  151. package/dist/types/geometries/point.d.ts +5 -13
  152. package/dist/types/geometries/poly.d.ts +26 -75
  153. package/dist/types/geometries/rectangle.d.ts +12 -58
  154. package/dist/types/geometries/roundrect.d.ts +2 -11
  155. package/dist/types/index.d.ts +3 -3
  156. package/dist/types/input/gamepad.d.ts +31 -31
  157. package/dist/types/input/keyboard.d.ts +105 -105
  158. package/dist/types/input/pointer.d.ts +21 -21
  159. package/dist/types/input/pointerevent.d.ts +6 -6
  160. package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
  161. package/dist/types/math/matrix2.d.ts +9 -63
  162. package/dist/types/math/matrix3.d.ts +9 -68
  163. package/dist/types/math/observable_vector2.d.ts +2 -2
  164. package/dist/types/math/observable_vector3.d.ts +2 -2
  165. package/dist/types/math/vector2.d.ts +8 -92
  166. package/dist/types/math/vector3.d.ts +8 -92
  167. package/dist/types/particles/settings.d.ts +29 -29
  168. package/dist/types/physics/body.d.ts +10 -8
  169. package/dist/types/physics/bounds.d.ts +24 -30
  170. package/dist/types/physics/collision.d.ts +12 -12
  171. package/dist/types/physics/detector.d.ts +1 -1
  172. package/dist/types/physics/world.d.ts +4 -7
  173. package/dist/types/renderable/container.d.ts +19 -19
  174. package/dist/types/renderable/imagelayer.d.ts +6 -6
  175. package/dist/types/renderable/light2d.d.ts +7 -7
  176. package/dist/types/renderable/renderable.d.ts +9 -16
  177. package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
  178. package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
  179. package/dist/types/renderable/text/glyph.d.ts +28 -0
  180. package/dist/types/renderable/text/text.d.ts +159 -0
  181. package/dist/types/renderable/text/textmetrics.d.ts +47 -0
  182. package/dist/types/renderable/text/textstyle.d.ts +5 -0
  183. package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
  184. package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
  185. package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
  186. package/dist/types/state/state.d.ts +11 -11
  187. package/dist/types/system/device.d.ts +15 -9
  188. package/dist/types/system/event.d.ts +20 -0
  189. package/dist/types/system/platform.d.ts +17 -17
  190. package/dist/types/utils/function.d.ts +1 -2
  191. package/dist/types/video/renderer.d.ts +13 -13
  192. package/dist/types/video/texture/canvas_texture.d.ts +14 -14
  193. package/dist/types/video/video.d.ts +2 -2
  194. package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
  195. package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
  196. package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
  197. package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
  198. package/dist/types/video/webgl/utils/precision.d.ts +1 -1
  199. package/dist/types/video/webgl/webgl_renderer.d.ts +47 -50
  200. package/package.json +15 -15
  201. package/src/application/application.js +51 -3
  202. package/src/application/header.js +1 -1
  203. package/src/application/resize.js +3 -7
  204. package/src/application/settings.js +4 -4
  205. package/src/audio/audio.js +3 -5
  206. package/src/camera/camera2d.js +11 -13
  207. package/src/entity/entity.js +2 -3
  208. package/src/geometries/ellipse.js +25 -58
  209. package/src/geometries/line.js +17 -24
  210. package/src/geometries/path2d.js +15 -12
  211. package/src/geometries/point.js +7 -15
  212. package/src/geometries/poly.js +39 -96
  213. package/src/geometries/rectangle.js +36 -90
  214. package/src/geometries/roundrect.js +25 -34
  215. package/src/index.js +4 -4
  216. package/src/input/keyboard.js +2 -2
  217. package/src/input/pointer.js +3 -3
  218. package/src/input/pointerevent.js +5 -6
  219. package/src/lang/deprecated.js +1 -1
  220. package/src/level/tiled/TMXLayer.js +15 -32
  221. package/src/level/tiled/TMXObject.js +2 -3
  222. package/src/level/tiled/TMXTile.js +3 -3
  223. package/src/level/tiled/TMXTileMap.js +2 -2
  224. package/src/level/tiled/TMXTileset.js +3 -6
  225. package/src/level/tiled/TMXTilesetGroup.js +1 -1
  226. package/src/level/tiled/TMXUtils.js +25 -28
  227. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
  228. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  229. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  230. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  231. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  232. package/src/loader/parser.js +3 -4
  233. package/src/math/color.js +1 -1
  234. package/src/math/matrix2.js +4 -58
  235. package/src/math/matrix3.js +81 -140
  236. package/src/math/observable_vector2.js +6 -6
  237. package/src/math/observable_vector3.js +4 -4
  238. package/src/math/vector2.js +6 -90
  239. package/src/math/vector3.js +5 -89
  240. package/src/particles/emitter.js +1 -1
  241. package/src/particles/particle.js +1 -1
  242. package/src/physics/body.js +21 -19
  243. package/src/physics/bounds.js +26 -32
  244. package/src/physics/collision.js +4 -4
  245. package/src/physics/detector.js +9 -9
  246. package/src/physics/quadtree.js +4 -4
  247. package/src/physics/sat.js +2 -3
  248. package/src/physics/world.js +5 -8
  249. package/src/polyfill/roundrect.js +163 -163
  250. package/src/renderable/collectable.js +1 -1
  251. package/src/renderable/colorlayer.js +3 -3
  252. package/src/renderable/container.js +24 -24
  253. package/src/renderable/imagelayer.js +3 -3
  254. package/src/renderable/light2d.js +2 -2
  255. package/src/renderable/nineslicesprite.js +1 -1
  256. package/src/renderable/renderable.js +25 -25
  257. package/src/renderable/sprite.js +2 -2
  258. package/src/{text → renderable/text}/bitmaptext.js +8 -8
  259. package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
  260. package/src/{text → renderable/text}/glyph.js +1 -1
  261. package/src/{text → renderable/text}/text.js +16 -17
  262. package/src/{text → renderable/text}/textmetrics.js +2 -2
  263. package/src/renderable/trigger.js +9 -9
  264. package/src/renderable/ui/uibaseelement.js +6 -6
  265. package/src/renderable/ui/uispriteelement.js +6 -6
  266. package/src/renderable/ui/uitextbutton.js +2 -2
  267. package/src/state/stage.js +1 -1
  268. package/src/state/state.js +0 -49
  269. package/src/system/device.js +48 -9
  270. package/src/system/event.js +22 -0
  271. package/src/system/platform.js +18 -18
  272. package/src/system/pooling.js +9 -9
  273. package/src/tweens/tween.js +1 -1
  274. package/src/utils/function.js +1 -2
  275. package/src/video/canvas/canvas_renderer.js +2 -6
  276. package/src/video/renderer.js +15 -15
  277. package/src/video/texture/atlas.js +12 -12
  278. package/src/video/texture/canvas_texture.js +14 -14
  279. package/src/video/video.js +3 -3
  280. package/src/video/webgl/buffer/vertex.js +2 -2
  281. package/src/video/webgl/compositors/compositor.js +12 -13
  282. package/src/video/webgl/compositors/primitive_compositor.js +4 -4
  283. package/src/video/webgl/compositors/quad_compositor.js +1 -2
  284. package/src/video/webgl/glshader.js +1 -1
  285. package/src/video/webgl/utils/precision.js +3 -3
  286. package/src/video/webgl/webgl_renderer.js +49 -51
  287. /package/src/{text → renderable/text}/textstyle.js +0 -0
@@ -125,7 +125,7 @@ export function preloadTMX(tmxData, onload, onerror) {
125
125
  switch (format) {
126
126
  case "xml":
127
127
  case "tmx":
128
- case "tsx":
128
+ case "tsx": {
129
129
  // ie9 does not fully implement the responseXML
130
130
  if (ua.match(/msie/i) || !xmlhttp.responseXML) {
131
131
  if (globalThis.DOMParser) {
@@ -139,7 +139,7 @@ export function preloadTMX(tmxData, onload, onerror) {
139
139
  result = xmlhttp.responseXML;
140
140
  }
141
141
  // converts to a JS object
142
- var data = TMXUtils.parse(result); // <= "Unexpected lexical declaration in case block" if using let
142
+ const data = TMXUtils.parse(result);
143
143
  switch (format) {
144
144
  case "tmx":
145
145
  result = data.map;
@@ -149,9 +149,8 @@ export function preloadTMX(tmxData, onload, onerror) {
149
149
  result = data.tilesets[0];
150
150
  break;
151
151
  }
152
-
153
152
  break;
154
-
153
+ }
155
154
  case "json":
156
155
  case "tmj":
157
156
  case "tsj":
package/src/math/color.js CHANGED
@@ -182,7 +182,7 @@ let cssToRGB = new Map();
182
182
  * @classdesc
183
183
  * A color manipulation object.
184
184
  */
185
- export default class Color {
185
+ export default class Color {
186
186
  /**
187
187
  * @param {number} [r=0] - red component or array of color components
188
188
  * @param {number} [g=0] - green component
@@ -7,7 +7,7 @@ import Matrix3d from "./matrix3.js";
7
7
  * the identity matrix and parameters position : <br>
8
8
  * <img src="images/identity-matrix_2x.png"/>
9
9
  */
10
- export default class Matrix2d {
10
+ export default class Matrix2d {
11
11
  /**
12
12
  * @param {(Matrix2d|Matrix3d|...number)} args - an instance of me.Matrix2d or me.Matrix3d to copy from, or individual matrix components (See {@link Matrix2d.setTransform}). If not arguments are given, the matrix will be set to Identity.
13
13
  */
@@ -40,11 +40,8 @@ import Matrix3d from "./matrix3.js";
40
40
 
41
41
  /**
42
42
  * tx component of the matrix
43
- * @public
44
43
  * @type {number}
45
44
  * @see Matrix2d.translate
46
- * @name tx
47
- * @memberof Matrix2d
48
45
  */
49
46
  get tx() {
50
47
  return this.val[6];
@@ -52,11 +49,8 @@ import Matrix3d from "./matrix3.js";
52
49
 
53
50
  /**
54
51
  * ty component of the matrix
55
- * @public
56
52
  * @type {number}
57
53
  * @see Matrix2d.translate
58
- * @name ty
59
- * @memberof Matrix2d
60
54
  */
61
55
  get ty() {
62
56
  return this.val[7];
@@ -66,8 +60,6 @@ import Matrix3d from "./matrix3.js";
66
60
  * reset the transformation matrix to the identity matrix (no transformation).<br>
67
61
  * the identity matrix and parameters position : <br>
68
62
  * <img src="images/identity-matrix_2x.png"/>
69
- * @name identity
70
- * @memberof Matrix2d
71
63
  * @returns {Matrix2d} Reference to this object for method chaining
72
64
  */
73
65
  identity() {
@@ -81,8 +73,6 @@ import Matrix3d from "./matrix3.js";
81
73
 
82
74
  /**
83
75
  * set the matrix to the specified value
84
- * @name setTransform
85
- * @memberof Matrix2d
86
76
  * @param {number} a
87
77
  * @param {number} b
88
78
  * @param {number} c
@@ -124,8 +114,6 @@ import Matrix3d from "./matrix3.js";
124
114
 
125
115
  /**
126
116
  * Copies over the values from another me.Matrix2d.
127
- * @name copy
128
- * @memberof Matrix2d
129
117
  * @param {Matrix2d} m - the matrix object to copy from
130
118
  * @returns {Matrix2d} Reference to this object for method chaining
131
119
  */
@@ -136,8 +124,6 @@ import Matrix3d from "./matrix3.js";
136
124
 
137
125
  /**
138
126
  * Copies over the upper-left 3x3 values from the given me.Matrix3d
139
- * @name fromMat3d
140
- * @memberof Matrix2d
141
127
  * @param {Matrix3d} m - the matrix object to copy from
142
128
  * @returns {Matrix2d} Reference to this object for method chaining
143
129
  */
@@ -160,8 +146,6 @@ import Matrix3d from "./matrix3.js";
160
146
 
161
147
  /**
162
148
  * multiply both matrix
163
- * @name multiply
164
- * @memberof Matrix2d
165
149
  * @param {Matrix2d} m - the other matrix
166
150
  * @returns {Matrix2d} Reference to this object for method chaining
167
151
  */
@@ -191,8 +175,6 @@ import Matrix3d from "./matrix3.js";
191
175
 
192
176
  /**
193
177
  * Transpose the value of this matrix.
194
- * @name transpose
195
- * @memberof Matrix2d
196
178
  * @returns {Matrix2d} Reference to this object for method chaining
197
179
  */
198
180
  transpose() {
@@ -213,8 +195,6 @@ import Matrix3d from "./matrix3.js";
213
195
 
214
196
  /**
215
197
  * invert this matrix, causing it to apply the opposite transformation.
216
- * @name invert
217
- * @memberof Matrix2d
218
198
  * @returns {Matrix2d} Reference to this object for method chaining
219
199
  */
220
200
  invert() {
@@ -245,10 +225,8 @@ import Matrix3d from "./matrix3.js";
245
225
  return this;
246
226
  }
247
227
 
248
- /**
228
+ /**
249
229
  * apply the current transform to the given 2d or 3d vector
250
- * @name apply
251
- * @memberof Matrix2d
252
230
  * @param {Vector2d|Vector3d} v - the vector object to be transformed
253
231
  * @returns {Vector2d|Vector3d} result vector object.
254
232
  */
@@ -270,8 +248,6 @@ import Matrix3d from "./matrix3.js";
270
248
 
271
249
  /**
272
250
  * apply the inverted current transform to the given 2d vector
273
- * @name applyInverse
274
- * @memberof Matrix2d
275
251
  * @param {Vector2d} v - the vector object to be transformed
276
252
  * @returns {Vector2d} result vector object.
277
253
  */
@@ -290,8 +266,6 @@ import Matrix3d from "./matrix3.js";
290
266
 
291
267
  /**
292
268
  * scale the matrix
293
- * @name scale
294
- * @memberof Matrix2d
295
269
  * @param {number} x - a number representing the abscissa of the scaling vector.
296
270
  * @param {number} [y=x] - a number representing the ordinate of the scaling vector.
297
271
  * @returns {Matrix2d} Reference to this object for method chaining
@@ -309,8 +283,6 @@ import Matrix3d from "./matrix3.js";
309
283
 
310
284
  /**
311
285
  * adds a 2D scaling transformation.
312
- * @name scaleV
313
- * @memberof Matrix2d
314
286
  * @param {Vector2d} v - scaling vector
315
287
  * @returns {Matrix2d} Reference to this object for method chaining
316
288
  */
@@ -320,8 +292,6 @@ import Matrix3d from "./matrix3.js";
320
292
 
321
293
  /**
322
294
  * specifies a 2D scale operation using the [sx, 1] scaling vector
323
- * @name scaleX
324
- * @memberof Matrix2d
325
295
  * @param {number} x - x scaling vector
326
296
  * @returns {Matrix2d} Reference to this object for method chaining
327
297
  */
@@ -331,8 +301,6 @@ import Matrix3d from "./matrix3.js";
331
301
 
332
302
  /**
333
303
  * specifies a 2D scale operation using the [1,sy] scaling vector
334
- * @name scaleY
335
- * @memberof Matrix2d
336
304
  * @param {number} y - y scaling vector
337
305
  * @returns {Matrix2d} Reference to this object for method chaining
338
306
  */
@@ -342,8 +310,6 @@ import Matrix3d from "./matrix3.js";
342
310
 
343
311
  /**
344
312
  * rotate the matrix (counter-clockwise) by the specified angle (in radians).
345
- * @name rotate
346
- * @memberof Matrix2d
347
313
  * @param {number} angle - Rotation angle in radians.
348
314
  * @returns {Matrix2d} Reference to this object for method chaining
349
315
  */
@@ -372,18 +338,8 @@ import Matrix3d from "./matrix3.js";
372
338
 
373
339
  /**
374
340
  * translate the matrix position on the horizontal and vertical axis
375
- * @name translate
376
- * @memberof Matrix2d
377
- * @method
378
- * @param {number} x - the x coordindates to translate the matrix by
379
- * @param {number} y - the y coordindates to translate the matrix by
380
- * @returns {Matrix2d} Reference to this object for method chaining
381
- */
382
- /**
383
- * translate the matrix by a vector on the horizontal and vertical axis
384
- * @name translateV
385
- * @memberof Matrix2d
386
- * @param {Vector2d} v - the vector to translate the matrix by
341
+ * @param {number|Vector2d} x - the x coordindates or a vector to translate the matrix by
342
+ * @param {number} [y] - the y coordindates to translate the matrix by
387
343
  * @returns {Matrix2d} Reference to this object for method chaining
388
344
  */
389
345
  translate() {
@@ -408,8 +364,6 @@ import Matrix3d from "./matrix3.js";
408
364
 
409
365
  /**
410
366
  * returns true if the matrix is an identity matrix.
411
- * @name isIdentity
412
- * @memberof Matrix2d
413
367
  * @returns {boolean}
414
368
  */
415
369
  isIdentity() {
@@ -430,8 +384,6 @@ import Matrix3d from "./matrix3.js";
430
384
 
431
385
  /**
432
386
  * return true if the two matrices are identical
433
- * @name equals
434
- * @memberof Matrix2d
435
387
  * @param {Matrix2d} m - the other matrix
436
388
  * @returns {boolean} true if both are equals
437
389
  */
@@ -454,8 +406,6 @@ import Matrix3d from "./matrix3.js";
454
406
 
455
407
  /**
456
408
  * Clone the Matrix
457
- * @name clone
458
- * @memberof Matrix2d
459
409
  * @returns {Matrix2d}
460
410
  */
461
411
  clone() {
@@ -464,8 +414,6 @@ import Matrix3d from "./matrix3.js";
464
414
 
465
415
  /**
466
416
  * return an array representation of this Matrix
467
- * @name toArray
468
- * @memberof Matrix2d
469
417
  * @returns {Float32Array}
470
418
  */
471
419
  toArray() {
@@ -474,8 +422,6 @@ import Matrix3d from "./matrix3.js";
474
422
 
475
423
  /**
476
424
  * convert the object to a string representation
477
- * @name toString
478
- * @memberof Matrix2d
479
425
  * @returns {string}
480
426
  */
481
427
  toString() {
@@ -5,7 +5,7 @@ import { EPSILON } from "./math.js";
5
5
  * @classdesc
6
6
  * a 4x4 Matrix3d Object
7
7
  */
8
- export default class Matrix3d {
8
+ export default class Matrix3d {
9
9
  /**
10
10
  * @param {(Matrix3d|...number)} args - An instance of me.Matrix3d to copy from, or individual Matrix components (See {@link Matrix3d.setTransform}). If not arguments are given, the matrix will be set to Identity.
11
11
  */
@@ -34,10 +34,7 @@ import { EPSILON } from "./math.js";
34
34
 
35
35
  /**
36
36
  * tx component of the matrix
37
- * @public
38
37
  * @type {number}
39
- * @name tx
40
- * @memberof Matrix3d
41
38
  */
42
39
  get tx() {
43
40
  return this.val[12];
@@ -45,10 +42,7 @@ import { EPSILON } from "./math.js";
45
42
 
46
43
  /**
47
44
  * ty component of the matrix
48
- * @public
49
45
  * @type {number}
50
- * @name ty
51
- * @memberof Matrix3d
52
46
  */
53
47
  get ty() {
54
48
  return this.val[13];
@@ -56,10 +50,7 @@ import { EPSILON } from "./math.js";
56
50
 
57
51
  /**
58
52
  * ty component of the matrix
59
- * @public
60
53
  * @type {number}
61
- * @name tz
62
- * @memberof Matrix3d
63
54
  */
64
55
  get tz() {
65
56
  return this.val[14];
@@ -69,8 +60,6 @@ import { EPSILON } from "./math.js";
69
60
  * reset the transformation matrix to the identity matrix (no transformation).<br>
70
61
  * the identity matrix and parameters position : <br>
71
62
  * <img src="images/identity-matrix_2x.png"/>
72
- * @name identity
73
- * @memberof Matrix3d
74
63
  * @returns {Matrix3d} Reference to this object for method chaining
75
64
  */
76
65
  identity() {
@@ -84,8 +73,6 @@ import { EPSILON } from "./math.js";
84
73
 
85
74
  /**
86
75
  * set the matrix to the specified value
87
- * @name setTransform
88
- * @memberof Matrix3d
89
76
  * @param {number} m00
90
77
  * @param {number} m01
91
78
  * @param {number} m02
@@ -129,8 +116,6 @@ import { EPSILON } from "./math.js";
129
116
 
130
117
  /**
131
118
  * Copies over the values from another me.Matrix3d.
132
- * @name copy
133
- * @memberof Matrix3d
134
119
  * @param {Matrix3d} m - the matrix object to copy from
135
120
  * @returns {Matrix3d} Reference to this object for method chaining
136
121
  */
@@ -141,8 +126,6 @@ import { EPSILON } from "./math.js";
141
126
 
142
127
  /**
143
128
  * Copies over the upper-left 2x2 values from the given me.Matrix2d
144
- * @name fromMat2d
145
- * @memberof Matrix3d
146
129
  * @param {Matrix2d} m - the matrix object to copy from
147
130
  * @returns {Matrix2d} Reference to this object for method chaining
148
131
  */
@@ -159,8 +142,6 @@ import { EPSILON } from "./math.js";
159
142
 
160
143
  /**
161
144
  * multiply both matrix
162
- * @name multiply
163
- * @memberof Matrix3d
164
145
  * @param {Matrix3d} m - Other matrix
165
146
  * @returns {Matrix3d} Reference to this object for method chaining
166
147
  */
@@ -214,8 +195,6 @@ import { EPSILON } from "./math.js";
214
195
 
215
196
  /**
216
197
  * Transpose the value of this matrix.
217
- * @name transpose
218
- * @memberof Matrix3d
219
198
  * @returns {Matrix3d} Reference to this object for method chaining
220
199
  */
221
200
  transpose() {
@@ -227,93 +206,89 @@ import { EPSILON } from "./math.js";
227
206
  a13 = a[7],
228
207
  a23 = a[11];
229
208
 
230
- a[1] = a[4];
231
- a[2] = a[8];
232
- a[3] = a[12];
233
- a[4] = a01;
234
- a[6] = a[9];
235
- a[7] = a[13];
236
- a[8] = a02;
237
- a[9] = a12;
238
- a[11] = a[14];
239
- a[12] = a03;
240
- a[13] = a13;
241
- a[14] = a23;
242
-
243
- return this;
209
+ a[1] = a[4];
210
+ a[2] = a[8];
211
+ a[3] = a[12];
212
+ a[4] = a01;
213
+ a[6] = a[9];
214
+ a[7] = a[13];
215
+ a[8] = a02;
216
+ a[9] = a12;
217
+ a[11] = a[14];
218
+ a[12] = a03;
219
+ a[13] = a13;
220
+ a[14] = a23;
221
+
222
+ return this;
244
223
  }
245
224
 
246
225
  /**
247
226
  * invert this matrix, causing it to apply the opposite transformation.
248
- * @name invert
249
- * @memberof Matrix3d
250
227
  * @returns {Matrix3d} Reference to this object for method chaining
251
228
  */
252
229
  invert() {
253
- let a = this.val;
254
-
255
- let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
256
- let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
257
- let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
258
- let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
259
-
260
- let b00 = a00 * a11 - a01 * a10;
261
- let b01 = a00 * a12 - a02 * a10;
262
- let b02 = a00 * a13 - a03 * a10;
263
- let b03 = a01 * a12 - a02 * a11;
264
-
265
- let b04 = a01 * a13 - a03 * a11;
266
- let b05 = a02 * a13 - a03 * a12;
267
- let b06 = a20 * a31 - a21 * a30;
268
- let b07 = a20 * a32 - a22 * a30;
269
-
270
- let b08 = a20 * a33 - a23 * a30;
271
- let b09 = a21 * a32 - a22 * a31;
272
- let b10 = a21 * a33 - a23 * a31;
273
- let b11 = a22 * a33 - a23 * a32;
274
-
275
- // Calculate the determinant
276
- let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
277
-
278
- if (!det)
279
- {
280
- return null;
281
- }
282
-
283
- det = 1 / det;
284
-
285
- a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
286
- a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
287
- a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
288
- a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
289
- a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
290
- a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
291
- a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
292
- a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
293
- a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
294
- a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
295
- a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
296
- a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
297
- a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
298
- a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
299
- a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
300
- a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
301
-
302
- return this;
230
+ let a = this.val;
231
+
232
+ let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
233
+ let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
234
+ let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
235
+ let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
236
+
237
+ let b00 = a00 * a11 - a01 * a10;
238
+ let b01 = a00 * a12 - a02 * a10;
239
+ let b02 = a00 * a13 - a03 * a10;
240
+ let b03 = a01 * a12 - a02 * a11;
241
+
242
+ let b04 = a01 * a13 - a03 * a11;
243
+ let b05 = a02 * a13 - a03 * a12;
244
+ let b06 = a20 * a31 - a21 * a30;
245
+ let b07 = a20 * a32 - a22 * a30;
246
+
247
+ let b08 = a20 * a33 - a23 * a30;
248
+ let b09 = a21 * a32 - a22 * a31;
249
+ let b10 = a21 * a33 - a23 * a31;
250
+ let b11 = a22 * a33 - a23 * a32;
251
+
252
+ // Calculate the determinant
253
+ let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
254
+
255
+ if (!det)
256
+ {
257
+ return null;
258
+ }
259
+
260
+ det = 1 / det;
261
+
262
+ a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
263
+ a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
264
+ a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
265
+ a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
266
+ a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
267
+ a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
268
+ a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
269
+ a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
270
+ a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
271
+ a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
272
+ a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
273
+ a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
274
+ a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
275
+ a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
276
+ a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
277
+ a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
278
+
279
+ return this;
303
280
  }
304
281
 
305
282
  /**
306
283
  * apply the current transform to the given 2d or 3d vector
307
- * @name apply
308
- * @memberof Matrix3d
309
284
  * @param {Vector2d|Vector3d} v - the vector object to be transformed
310
285
  * @returns {Vector2d|Vector3d} result vector object.
311
286
  */
312
- apply(v) {
287
+ apply(v) {
313
288
  let a = this.val,
314
- x = v.x,
315
- y = v.y,
316
- z = (typeof v.z !== "undefined") ? v.z : 1;
289
+ x = v.x,
290
+ y = v.y,
291
+ z = (typeof v.z !== "undefined") ? v.z : 1;
317
292
 
318
293
  let w = (a[3] * x + a[7] * y + a[11] * z + a[15]) || 1.0;
319
294
 
@@ -325,32 +300,28 @@ import { EPSILON } from "./math.js";
325
300
  }
326
301
 
327
302
  return v;
328
- }
303
+ }
329
304
 
330
- /**
305
+ /**
331
306
  * apply the inverted current transform to the given 2d or 3d vector
332
- * @name applyInverse
333
- * @memberof Matrix3d
334
307
  * @param {Vector2d|Vector3d} v - the vector object to be transformed
335
308
  * @returns {Vector2d|Vector3d} result vector object.
336
309
  */
337
- applyInverse(v) {
338
- // invert the current matrix
339
- let im = pool.pull("Matrix3d", this).invert();
310
+ applyInverse(v) {
311
+ // invert the current matrix
312
+ let im = pool.pull("Matrix3d", this).invert();
340
313
 
341
- // apply the inverted matrix
342
- im.apply(v);
314
+ // apply the inverted matrix
315
+ im.apply(v);
343
316
 
344
- pool.push(im);
317
+ pool.push(im);
345
318
 
346
- return v;
347
- }
319
+ return v;
320
+ }
348
321
 
349
322
  /**
350
323
  * generate an orthogonal projection matrix, with the result replacing the current matrix
351
324
  * <img src="images/glOrtho.gif"/><br>
352
- * @name ortho
353
- * @memberof Matrix3d
354
325
  * @param {number} left - farthest left on the x-axis
355
326
  * @param {number} right - farthest right on the x-axis
356
327
  * @param {number} bottom - farthest down on the y-axis
@@ -387,8 +358,6 @@ import { EPSILON } from "./math.js";
387
358
 
388
359
  /**
389
360
  * scale the matrix
390
- * @name scale
391
- * @memberof Matrix3d
392
361
  * @param {number} x - a number representing the abscissa of the scaling vector.
393
362
  * @param {number} [y=x] - a number representing the ordinate of the scaling vector.
394
363
  * @param {number} [z=0] - a number representing the depth vector
@@ -417,8 +386,6 @@ import { EPSILON } from "./math.js";
417
386
 
418
387
  /**
419
388
  * adds a 2D scaling transformation.
420
- * @name scaleV
421
- * @memberof Matrix3d
422
389
  * @param {Vector2d|Vector3d} v - scaling vector
423
390
  * @returns {Matrix3d} Reference to this object for method chaining
424
391
  */
@@ -428,8 +395,6 @@ import { EPSILON } from "./math.js";
428
395
 
429
396
  /**
430
397
  * specifies a 2D scale operation using the [sx, 1] scaling vector
431
- * @name scaleX
432
- * @memberof Matrix3d
433
398
  * @param {number} x - x scaling vector
434
399
  * @returns {Matrix3d} Reference to this object for method chaining
435
400
  */
@@ -439,8 +404,6 @@ import { EPSILON } from "./math.js";
439
404
 
440
405
  /**
441
406
  * specifies a 2D scale operation using the [1,sy] scaling vector
442
- * @name scaleY
443
- * @memberof Matrix3d
444
407
  * @param {number} y - y scaling vector
445
408
  * @returns {Matrix3d} Reference to this object for method chaining
446
409
  */
@@ -450,8 +413,6 @@ import { EPSILON } from "./math.js";
450
413
 
451
414
  /**
452
415
  * rotate this matrix (counter-clockwise) by the specified angle (in radians).
453
- * @name rotate
454
- * @memberof Matrix3d
455
416
  * @param {number} angle - Rotation angle in radians.
456
417
  * @param {Vector3d} v - the axis to rotate around
457
418
  * @returns {Matrix3d} Reference to this object for method chaining
@@ -529,21 +490,11 @@ import { EPSILON } from "./math.js";
529
490
 
530
491
  /**
531
492
  * translate the matrix position using the given vector
532
- * @name translate
533
- * @memberof Matrix3d
534
- * @method
535
- * @param {number} x - a number representing the abscissa of the vector.
536
- * @param {number} [y=x] - a number representing the ordinate of the vector.
493
+ * @param {number|Vector2d|Vector3d} x - a number representing the abscissa of the vector, or a vector object
494
+ * @param {number} [y] - a number representing the ordinate of the vector.
537
495
  * @param {number} [z=0] - a number representing the depth of the vector
538
496
  * @returns {Matrix3d} Reference to this object for method chaining
539
497
  */
540
- /**
541
- * translate the matrix by a vector on the horizontal and vertical axis
542
- * @name translateV
543
- * @memberof Matrix3d
544
- * @param {Vector2d|Vector3d} v - the vector to translate the matrix by
545
- * @returns {Matrix3d} Reference to this object for method chaining
546
- */
547
498
  translate() {
548
499
  let a = this.val;
549
500
  let _x, _y, _z;
@@ -570,8 +521,6 @@ import { EPSILON } from "./math.js";
570
521
 
571
522
  /**
572
523
  * returns true if the matrix is an identity matrix.
573
- * @name isIdentity
574
- * @memberof Matrix3d
575
524
  * @returns {boolean}
576
525
  */
577
526
  isIdentity() {
@@ -599,8 +548,6 @@ import { EPSILON } from "./math.js";
599
548
 
600
549
  /**
601
550
  * return true if the two matrices are identical
602
- * @name equals
603
- * @memberof Matrix3d
604
551
  * @param {Matrix3d} m - the other matrix
605
552
  * @returns {boolean} true if both are equals
606
553
  */
@@ -630,8 +577,6 @@ import { EPSILON } from "./math.js";
630
577
 
631
578
  /**
632
579
  * Clone the Matrix
633
- * @name clone
634
- * @memberof Matrix3d
635
580
  * @returns {Matrix3d}
636
581
  */
637
582
  clone() {
@@ -640,8 +585,6 @@ import { EPSILON } from "./math.js";
640
585
 
641
586
  /**
642
587
  * return an array representation of this Matrix
643
- * @name toArray
644
- * @memberof Matrix3d
645
588
  * @returns {Float32Array}
646
589
  */
647
590
  toArray() {
@@ -650,8 +593,6 @@ import { EPSILON } from "./math.js";
650
593
 
651
594
  /**
652
595
  * convert the object to a string representation
653
- * @name toString
654
- * @memberof Matrix3d
655
596
  * @returns {string}
656
597
  */
657
598
  toString() {