melonjs 15.3.0 → 15.4.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.
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +1 -1
- package/dist/melonjs.mjs/application/application.js +53 -5
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +4 -8
- package/dist/melonjs.mjs/application/settings.js +5 -5
- package/dist/melonjs.mjs/audio/audio.js +4 -6
- package/dist/melonjs.mjs/camera/camera2d.js +12 -14
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
- package/dist/melonjs.mjs/geometries/line.js +18 -25
- package/dist/melonjs.mjs/geometries/path2d.js +16 -13
- package/dist/melonjs.mjs/geometries/point.js +8 -16
- package/dist/melonjs.mjs/geometries/poly.js +40 -97
- package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
- package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
- package/dist/melonjs.mjs/index.js +6 -6
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +3 -3
- package/dist/melonjs.mjs/input/pointer.js +4 -4
- package/dist/melonjs.mjs/input/pointerevent.js +6 -7
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +26 -29
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +4 -5
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +2 -2
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +5 -59
- package/dist/melonjs.mjs/math/matrix3.js +82 -141
- package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
- package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
- package/dist/melonjs.mjs/math/vector2.js +7 -91
- package/dist/melonjs.mjs/math/vector3.js +6 -90
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +22 -20
- package/dist/melonjs.mjs/physics/bounds.js +27 -33
- package/dist/melonjs.mjs/physics/collision.js +5 -5
- package/dist/melonjs.mjs/physics/detector.js +10 -10
- package/dist/melonjs.mjs/physics/quadtree.js +5 -5
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +3 -4
- package/dist/melonjs.mjs/physics/world.js +6 -9
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
- package/dist/melonjs.mjs/renderable/container.js +25 -25
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
- package/dist/melonjs.mjs/renderable/light2d.js +3 -3
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +26 -26
- package/dist/melonjs.mjs/renderable/sprite.js +3 -3
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
- package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
- package/dist/melonjs.mjs/renderable/text/text.js +422 -0
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
- package/dist/melonjs.mjs/renderable/trigger.js +10 -10
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
- package/dist/melonjs.mjs/state/stage.js +2 -2
- package/dist/melonjs.mjs/state/state.js +1 -38
- package/dist/melonjs.mjs/system/device.js +49 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +24 -2
- package/dist/melonjs.mjs/system/platform.js +18 -18
- package/dist/melonjs.mjs/system/pooling.js +10 -10
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +2 -2
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +2 -3
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +3 -7
- package/dist/melonjs.mjs/video/renderer.js +16 -16
- package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +4 -4
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +50 -52
- package/dist/melonjs.module.js +1137 -1576
- package/dist/types/application/application.d.ts +28 -4
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +23 -23
- package/dist/types/audio/audio.d.ts +4 -6
- package/dist/types/camera/camera2d.d.ts +13 -16
- package/dist/types/entity/entity.d.ts +0 -1
- package/dist/types/geometries/ellipse.d.ts +18 -50
- package/dist/types/geometries/path2d.d.ts +1 -1
- package/dist/types/geometries/point.d.ts +5 -13
- package/dist/types/geometries/poly.d.ts +26 -75
- package/dist/types/geometries/rectangle.d.ts +12 -58
- package/dist/types/geometries/roundrect.d.ts +2 -11
- package/dist/types/index.d.ts +3 -3
- package/dist/types/input/gamepad.d.ts +31 -31
- package/dist/types/input/keyboard.d.ts +105 -105
- package/dist/types/input/pointer.d.ts +21 -21
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
- package/dist/types/math/matrix2.d.ts +9 -63
- package/dist/types/math/matrix3.d.ts +9 -68
- package/dist/types/math/observable_vector2.d.ts +2 -2
- package/dist/types/math/observable_vector3.d.ts +2 -2
- package/dist/types/math/vector2.d.ts +8 -92
- package/dist/types/math/vector3.d.ts +8 -92
- package/dist/types/particles/settings.d.ts +29 -29
- package/dist/types/physics/body.d.ts +10 -8
- package/dist/types/physics/bounds.d.ts +24 -30
- package/dist/types/physics/collision.d.ts +12 -12
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/physics/world.d.ts +4 -7
- package/dist/types/renderable/container.d.ts +19 -19
- package/dist/types/renderable/imagelayer.d.ts +6 -6
- package/dist/types/renderable/light2d.d.ts +7 -7
- package/dist/types/renderable/renderable.d.ts +9 -16
- package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
- package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/renderable/text/glyph.d.ts +28 -0
- package/dist/types/renderable/text/text.d.ts +159 -0
- package/dist/types/renderable/text/textmetrics.d.ts +47 -0
- package/dist/types/renderable/text/textstyle.d.ts +5 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
- package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
- package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +15 -9
- package/dist/types/system/event.d.ts +20 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/renderer.d.ts +13 -13
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +2 -2
- package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
- package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
- package/dist/types/video/webgl/utils/precision.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +47 -50
- package/package.json +15 -15
- package/src/application/application.js +51 -3
- package/src/application/header.js +1 -1
- package/src/application/resize.js +3 -7
- package/src/application/settings.js +4 -4
- package/src/audio/audio.js +3 -5
- package/src/camera/camera2d.js +11 -13
- package/src/entity/entity.js +2 -3
- package/src/geometries/ellipse.js +25 -58
- package/src/geometries/line.js +17 -24
- package/src/geometries/path2d.js +15 -12
- package/src/geometries/point.js +7 -15
- package/src/geometries/poly.js +39 -96
- package/src/geometries/rectangle.js +36 -90
- package/src/geometries/roundrect.js +25 -34
- package/src/index.js +4 -4
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +3 -3
- package/src/input/pointerevent.js +5 -6
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +15 -32
- package/src/level/tiled/TMXObject.js +2 -3
- package/src/level/tiled/TMXTile.js +3 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXTileset.js +3 -6
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +25 -28
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/parser.js +3 -4
- package/src/math/color.js +1 -1
- package/src/math/matrix2.js +4 -58
- package/src/math/matrix3.js +81 -140
- package/src/math/observable_vector2.js +6 -6
- package/src/math/observable_vector3.js +4 -4
- package/src/math/vector2.js +6 -90
- package/src/math/vector3.js +5 -89
- package/src/particles/emitter.js +1 -1
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +21 -19
- package/src/physics/bounds.js +26 -32
- package/src/physics/collision.js +4 -4
- package/src/physics/detector.js +9 -9
- package/src/physics/quadtree.js +4 -4
- package/src/physics/sat.js +2 -3
- package/src/physics/world.js +5 -8
- package/src/polyfill/roundrect.js +163 -163
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +3 -3
- package/src/renderable/container.js +24 -24
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +2 -2
- package/src/renderable/nineslicesprite.js +1 -1
- package/src/renderable/renderable.js +25 -25
- package/src/renderable/sprite.js +2 -2
- package/src/{text → renderable/text}/bitmaptext.js +8 -8
- package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
- package/src/{text → renderable/text}/glyph.js +1 -1
- package/src/{text → renderable/text}/text.js +16 -17
- package/src/{text → renderable/text}/textmetrics.js +2 -2
- package/src/renderable/trigger.js +9 -9
- package/src/renderable/ui/uibaseelement.js +6 -6
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +2 -2
- package/src/state/stage.js +1 -1
- package/src/state/state.js +0 -49
- package/src/system/device.js +48 -9
- package/src/system/event.js +22 -0
- package/src/system/platform.js +18 -18
- package/src/system/pooling.js +9 -9
- package/src/tweens/tween.js +1 -1
- package/src/utils/function.js +1 -2
- package/src/video/canvas/canvas_renderer.js +2 -6
- package/src/video/renderer.js +15 -15
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +3 -3
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +12 -13
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +1 -2
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/utils/precision.js +3 -3
- package/src/video/webgl/webgl_renderer.js +49 -51
- /package/src/{text → renderable/text}/textstyle.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -14,7 +14,7 @@ import Matrix3d from './matrix3.js';
|
|
|
14
14
|
* the identity matrix and parameters position : <br>
|
|
15
15
|
* <img src="images/identity-matrix_2x.png"/>
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
class Matrix2d {
|
|
18
18
|
/**
|
|
19
19
|
* @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.
|
|
20
20
|
*/
|
|
@@ -47,11 +47,8 @@ import Matrix3d from './matrix3.js';
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* tx component of the matrix
|
|
50
|
-
* @public
|
|
51
50
|
* @type {number}
|
|
52
51
|
* @see Matrix2d.translate
|
|
53
|
-
* @name tx
|
|
54
|
-
* @memberof Matrix2d
|
|
55
52
|
*/
|
|
56
53
|
get tx() {
|
|
57
54
|
return this.val[6];
|
|
@@ -59,11 +56,8 @@ import Matrix3d from './matrix3.js';
|
|
|
59
56
|
|
|
60
57
|
/**
|
|
61
58
|
* ty component of the matrix
|
|
62
|
-
* @public
|
|
63
59
|
* @type {number}
|
|
64
60
|
* @see Matrix2d.translate
|
|
65
|
-
* @name ty
|
|
66
|
-
* @memberof Matrix2d
|
|
67
61
|
*/
|
|
68
62
|
get ty() {
|
|
69
63
|
return this.val[7];
|
|
@@ -73,8 +67,6 @@ import Matrix3d from './matrix3.js';
|
|
|
73
67
|
* reset the transformation matrix to the identity matrix (no transformation).<br>
|
|
74
68
|
* the identity matrix and parameters position : <br>
|
|
75
69
|
* <img src="images/identity-matrix_2x.png"/>
|
|
76
|
-
* @name identity
|
|
77
|
-
* @memberof Matrix2d
|
|
78
70
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
79
71
|
*/
|
|
80
72
|
identity() {
|
|
@@ -88,8 +80,6 @@ import Matrix3d from './matrix3.js';
|
|
|
88
80
|
|
|
89
81
|
/**
|
|
90
82
|
* set the matrix to the specified value
|
|
91
|
-
* @name setTransform
|
|
92
|
-
* @memberof Matrix2d
|
|
93
83
|
* @param {number} a
|
|
94
84
|
* @param {number} b
|
|
95
85
|
* @param {number} c
|
|
@@ -131,8 +121,6 @@ import Matrix3d from './matrix3.js';
|
|
|
131
121
|
|
|
132
122
|
/**
|
|
133
123
|
* Copies over the values from another me.Matrix2d.
|
|
134
|
-
* @name copy
|
|
135
|
-
* @memberof Matrix2d
|
|
136
124
|
* @param {Matrix2d} m - the matrix object to copy from
|
|
137
125
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
138
126
|
*/
|
|
@@ -143,8 +131,6 @@ import Matrix3d from './matrix3.js';
|
|
|
143
131
|
|
|
144
132
|
/**
|
|
145
133
|
* Copies over the upper-left 3x3 values from the given me.Matrix3d
|
|
146
|
-
* @name fromMat3d
|
|
147
|
-
* @memberof Matrix2d
|
|
148
134
|
* @param {Matrix3d} m - the matrix object to copy from
|
|
149
135
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
150
136
|
*/
|
|
@@ -167,8 +153,6 @@ import Matrix3d from './matrix3.js';
|
|
|
167
153
|
|
|
168
154
|
/**
|
|
169
155
|
* multiply both matrix
|
|
170
|
-
* @name multiply
|
|
171
|
-
* @memberof Matrix2d
|
|
172
156
|
* @param {Matrix2d} m - the other matrix
|
|
173
157
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
174
158
|
*/
|
|
@@ -198,8 +182,6 @@ import Matrix3d from './matrix3.js';
|
|
|
198
182
|
|
|
199
183
|
/**
|
|
200
184
|
* Transpose the value of this matrix.
|
|
201
|
-
* @name transpose
|
|
202
|
-
* @memberof Matrix2d
|
|
203
185
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
204
186
|
*/
|
|
205
187
|
transpose() {
|
|
@@ -220,8 +202,6 @@ import Matrix3d from './matrix3.js';
|
|
|
220
202
|
|
|
221
203
|
/**
|
|
222
204
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
223
|
-
* @name invert
|
|
224
|
-
* @memberof Matrix2d
|
|
225
205
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
226
206
|
*/
|
|
227
207
|
invert() {
|
|
@@ -252,10 +232,8 @@ import Matrix3d from './matrix3.js';
|
|
|
252
232
|
return this;
|
|
253
233
|
}
|
|
254
234
|
|
|
255
|
-
|
|
235
|
+
/**
|
|
256
236
|
* apply the current transform to the given 2d or 3d vector
|
|
257
|
-
* @name apply
|
|
258
|
-
* @memberof Matrix2d
|
|
259
237
|
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
260
238
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
261
239
|
*/
|
|
@@ -277,8 +255,6 @@ import Matrix3d from './matrix3.js';
|
|
|
277
255
|
|
|
278
256
|
/**
|
|
279
257
|
* apply the inverted current transform to the given 2d vector
|
|
280
|
-
* @name applyInverse
|
|
281
|
-
* @memberof Matrix2d
|
|
282
258
|
* @param {Vector2d} v - the vector object to be transformed
|
|
283
259
|
* @returns {Vector2d} result vector object.
|
|
284
260
|
*/
|
|
@@ -297,8 +273,6 @@ import Matrix3d from './matrix3.js';
|
|
|
297
273
|
|
|
298
274
|
/**
|
|
299
275
|
* scale the matrix
|
|
300
|
-
* @name scale
|
|
301
|
-
* @memberof Matrix2d
|
|
302
276
|
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
303
277
|
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
304
278
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
@@ -316,8 +290,6 @@ import Matrix3d from './matrix3.js';
|
|
|
316
290
|
|
|
317
291
|
/**
|
|
318
292
|
* adds a 2D scaling transformation.
|
|
319
|
-
* @name scaleV
|
|
320
|
-
* @memberof Matrix2d
|
|
321
293
|
* @param {Vector2d} v - scaling vector
|
|
322
294
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
323
295
|
*/
|
|
@@ -327,8 +299,6 @@ import Matrix3d from './matrix3.js';
|
|
|
327
299
|
|
|
328
300
|
/**
|
|
329
301
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
330
|
-
* @name scaleX
|
|
331
|
-
* @memberof Matrix2d
|
|
332
302
|
* @param {number} x - x scaling vector
|
|
333
303
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
334
304
|
*/
|
|
@@ -338,8 +308,6 @@ import Matrix3d from './matrix3.js';
|
|
|
338
308
|
|
|
339
309
|
/**
|
|
340
310
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
341
|
-
* @name scaleY
|
|
342
|
-
* @memberof Matrix2d
|
|
343
311
|
* @param {number} y - y scaling vector
|
|
344
312
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
345
313
|
*/
|
|
@@ -349,8 +317,6 @@ import Matrix3d from './matrix3.js';
|
|
|
349
317
|
|
|
350
318
|
/**
|
|
351
319
|
* rotate the matrix (counter-clockwise) by the specified angle (in radians).
|
|
352
|
-
* @name rotate
|
|
353
|
-
* @memberof Matrix2d
|
|
354
320
|
* @param {number} angle - Rotation angle in radians.
|
|
355
321
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
356
322
|
*/
|
|
@@ -379,18 +345,8 @@ import Matrix3d from './matrix3.js';
|
|
|
379
345
|
|
|
380
346
|
/**
|
|
381
347
|
* translate the matrix position on the horizontal and vertical axis
|
|
382
|
-
* @
|
|
383
|
-
* @
|
|
384
|
-
* @method
|
|
385
|
-
* @param {number} x - the x coordindates to translate the matrix by
|
|
386
|
-
* @param {number} y - the y coordindates to translate the matrix by
|
|
387
|
-
* @returns {Matrix2d} Reference to this object for method chaining
|
|
388
|
-
*/
|
|
389
|
-
/**
|
|
390
|
-
* translate the matrix by a vector on the horizontal and vertical axis
|
|
391
|
-
* @name translateV
|
|
392
|
-
* @memberof Matrix2d
|
|
393
|
-
* @param {Vector2d} v - the vector to translate the matrix by
|
|
348
|
+
* @param {number|Vector2d} x - the x coordindates or a vector to translate the matrix by
|
|
349
|
+
* @param {number} [y] - the y coordindates to translate the matrix by
|
|
394
350
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
395
351
|
*/
|
|
396
352
|
translate() {
|
|
@@ -415,8 +371,6 @@ import Matrix3d from './matrix3.js';
|
|
|
415
371
|
|
|
416
372
|
/**
|
|
417
373
|
* returns true if the matrix is an identity matrix.
|
|
418
|
-
* @name isIdentity
|
|
419
|
-
* @memberof Matrix2d
|
|
420
374
|
* @returns {boolean}
|
|
421
375
|
*/
|
|
422
376
|
isIdentity() {
|
|
@@ -437,8 +391,6 @@ import Matrix3d from './matrix3.js';
|
|
|
437
391
|
|
|
438
392
|
/**
|
|
439
393
|
* return true if the two matrices are identical
|
|
440
|
-
* @name equals
|
|
441
|
-
* @memberof Matrix2d
|
|
442
394
|
* @param {Matrix2d} m - the other matrix
|
|
443
395
|
* @returns {boolean} true if both are equals
|
|
444
396
|
*/
|
|
@@ -461,8 +413,6 @@ import Matrix3d from './matrix3.js';
|
|
|
461
413
|
|
|
462
414
|
/**
|
|
463
415
|
* Clone the Matrix
|
|
464
|
-
* @name clone
|
|
465
|
-
* @memberof Matrix2d
|
|
466
416
|
* @returns {Matrix2d}
|
|
467
417
|
*/
|
|
468
418
|
clone() {
|
|
@@ -471,8 +421,6 @@ import Matrix3d from './matrix3.js';
|
|
|
471
421
|
|
|
472
422
|
/**
|
|
473
423
|
* return an array representation of this Matrix
|
|
474
|
-
* @name toArray
|
|
475
|
-
* @memberof Matrix2d
|
|
476
424
|
* @returns {Float32Array}
|
|
477
425
|
*/
|
|
478
426
|
toArray() {
|
|
@@ -481,8 +429,6 @@ import Matrix3d from './matrix3.js';
|
|
|
481
429
|
|
|
482
430
|
/**
|
|
483
431
|
* convert the object to a string representation
|
|
484
|
-
* @name toString
|
|
485
|
-
* @memberof Matrix2d
|
|
486
432
|
* @returns {string}
|
|
487
433
|
*/
|
|
488
434
|
toString() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -12,7 +12,7 @@ import { EPSILON } from './math.js';
|
|
|
12
12
|
* @classdesc
|
|
13
13
|
* a 4x4 Matrix3d Object
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
class Matrix3d {
|
|
16
16
|
/**
|
|
17
17
|
* @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.
|
|
18
18
|
*/
|
|
@@ -41,10 +41,7 @@ import { EPSILON } from './math.js';
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* tx component of the matrix
|
|
44
|
-
* @public
|
|
45
44
|
* @type {number}
|
|
46
|
-
* @name tx
|
|
47
|
-
* @memberof Matrix3d
|
|
48
45
|
*/
|
|
49
46
|
get tx() {
|
|
50
47
|
return this.val[12];
|
|
@@ -52,10 +49,7 @@ import { EPSILON } from './math.js';
|
|
|
52
49
|
|
|
53
50
|
/**
|
|
54
51
|
* ty component of the matrix
|
|
55
|
-
* @public
|
|
56
52
|
* @type {number}
|
|
57
|
-
* @name ty
|
|
58
|
-
* @memberof Matrix3d
|
|
59
53
|
*/
|
|
60
54
|
get ty() {
|
|
61
55
|
return this.val[13];
|
|
@@ -63,10 +57,7 @@ import { EPSILON } from './math.js';
|
|
|
63
57
|
|
|
64
58
|
/**
|
|
65
59
|
* ty component of the matrix
|
|
66
|
-
* @public
|
|
67
60
|
* @type {number}
|
|
68
|
-
* @name tz
|
|
69
|
-
* @memberof Matrix3d
|
|
70
61
|
*/
|
|
71
62
|
get tz() {
|
|
72
63
|
return this.val[14];
|
|
@@ -76,8 +67,6 @@ import { EPSILON } from './math.js';
|
|
|
76
67
|
* reset the transformation matrix to the identity matrix (no transformation).<br>
|
|
77
68
|
* the identity matrix and parameters position : <br>
|
|
78
69
|
* <img src="images/identity-matrix_2x.png"/>
|
|
79
|
-
* @name identity
|
|
80
|
-
* @memberof Matrix3d
|
|
81
70
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
82
71
|
*/
|
|
83
72
|
identity() {
|
|
@@ -91,8 +80,6 @@ import { EPSILON } from './math.js';
|
|
|
91
80
|
|
|
92
81
|
/**
|
|
93
82
|
* set the matrix to the specified value
|
|
94
|
-
* @name setTransform
|
|
95
|
-
* @memberof Matrix3d
|
|
96
83
|
* @param {number} m00
|
|
97
84
|
* @param {number} m01
|
|
98
85
|
* @param {number} m02
|
|
@@ -136,8 +123,6 @@ import { EPSILON } from './math.js';
|
|
|
136
123
|
|
|
137
124
|
/**
|
|
138
125
|
* Copies over the values from another me.Matrix3d.
|
|
139
|
-
* @name copy
|
|
140
|
-
* @memberof Matrix3d
|
|
141
126
|
* @param {Matrix3d} m - the matrix object to copy from
|
|
142
127
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
143
128
|
*/
|
|
@@ -148,8 +133,6 @@ import { EPSILON } from './math.js';
|
|
|
148
133
|
|
|
149
134
|
/**
|
|
150
135
|
* Copies over the upper-left 2x2 values from the given me.Matrix2d
|
|
151
|
-
* @name fromMat2d
|
|
152
|
-
* @memberof Matrix3d
|
|
153
136
|
* @param {Matrix2d} m - the matrix object to copy from
|
|
154
137
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
155
138
|
*/
|
|
@@ -166,8 +149,6 @@ import { EPSILON } from './math.js';
|
|
|
166
149
|
|
|
167
150
|
/**
|
|
168
151
|
* multiply both matrix
|
|
169
|
-
* @name multiply
|
|
170
|
-
* @memberof Matrix3d
|
|
171
152
|
* @param {Matrix3d} m - Other matrix
|
|
172
153
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
173
154
|
*/
|
|
@@ -221,8 +202,6 @@ import { EPSILON } from './math.js';
|
|
|
221
202
|
|
|
222
203
|
/**
|
|
223
204
|
* Transpose the value of this matrix.
|
|
224
|
-
* @name transpose
|
|
225
|
-
* @memberof Matrix3d
|
|
226
205
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
227
206
|
*/
|
|
228
207
|
transpose() {
|
|
@@ -234,93 +213,89 @@ import { EPSILON } from './math.js';
|
|
|
234
213
|
a13 = a[7],
|
|
235
214
|
a23 = a[11];
|
|
236
215
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
216
|
+
a[1] = a[4];
|
|
217
|
+
a[2] = a[8];
|
|
218
|
+
a[3] = a[12];
|
|
219
|
+
a[4] = a01;
|
|
220
|
+
a[6] = a[9];
|
|
221
|
+
a[7] = a[13];
|
|
222
|
+
a[8] = a02;
|
|
223
|
+
a[9] = a12;
|
|
224
|
+
a[11] = a[14];
|
|
225
|
+
a[12] = a03;
|
|
226
|
+
a[13] = a13;
|
|
227
|
+
a[14] = a23;
|
|
228
|
+
|
|
229
|
+
return this;
|
|
251
230
|
}
|
|
252
231
|
|
|
253
232
|
/**
|
|
254
233
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
255
|
-
* @name invert
|
|
256
|
-
* @memberof Matrix3d
|
|
257
234
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
258
235
|
*/
|
|
259
236
|
invert() {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
237
|
+
let a = this.val;
|
|
238
|
+
|
|
239
|
+
let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
|
|
240
|
+
let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
|
|
241
|
+
let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
|
|
242
|
+
let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
|
|
243
|
+
|
|
244
|
+
let b00 = a00 * a11 - a01 * a10;
|
|
245
|
+
let b01 = a00 * a12 - a02 * a10;
|
|
246
|
+
let b02 = a00 * a13 - a03 * a10;
|
|
247
|
+
let b03 = a01 * a12 - a02 * a11;
|
|
248
|
+
|
|
249
|
+
let b04 = a01 * a13 - a03 * a11;
|
|
250
|
+
let b05 = a02 * a13 - a03 * a12;
|
|
251
|
+
let b06 = a20 * a31 - a21 * a30;
|
|
252
|
+
let b07 = a20 * a32 - a22 * a30;
|
|
253
|
+
|
|
254
|
+
let b08 = a20 * a33 - a23 * a30;
|
|
255
|
+
let b09 = a21 * a32 - a22 * a31;
|
|
256
|
+
let b10 = a21 * a33 - a23 * a31;
|
|
257
|
+
let b11 = a22 * a33 - a23 * a32;
|
|
258
|
+
|
|
259
|
+
// Calculate the determinant
|
|
260
|
+
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
261
|
+
|
|
262
|
+
if (!det)
|
|
263
|
+
{
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
det = 1 / det;
|
|
268
|
+
|
|
269
|
+
a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
270
|
+
a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
271
|
+
a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
272
|
+
a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
273
|
+
a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
274
|
+
a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
275
|
+
a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
276
|
+
a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
277
|
+
a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
278
|
+
a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
279
|
+
a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
280
|
+
a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
281
|
+
a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
282
|
+
a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
283
|
+
a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
284
|
+
a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
285
|
+
|
|
286
|
+
return this;
|
|
310
287
|
}
|
|
311
288
|
|
|
312
289
|
/**
|
|
313
290
|
* apply the current transform to the given 2d or 3d vector
|
|
314
|
-
* @name apply
|
|
315
|
-
* @memberof Matrix3d
|
|
316
291
|
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
317
292
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
318
293
|
*/
|
|
319
|
-
|
|
294
|
+
apply(v) {
|
|
320
295
|
let a = this.val,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
296
|
+
x = v.x,
|
|
297
|
+
y = v.y,
|
|
298
|
+
z = (typeof v.z !== "undefined") ? v.z : 1;
|
|
324
299
|
|
|
325
300
|
let w = (a[3] * x + a[7] * y + a[11] * z + a[15]) || 1.0;
|
|
326
301
|
|
|
@@ -332,32 +307,28 @@ import { EPSILON } from './math.js';
|
|
|
332
307
|
}
|
|
333
308
|
|
|
334
309
|
return v;
|
|
335
|
-
|
|
310
|
+
}
|
|
336
311
|
|
|
337
|
-
|
|
312
|
+
/**
|
|
338
313
|
* apply the inverted current transform to the given 2d or 3d vector
|
|
339
|
-
* @name applyInverse
|
|
340
|
-
* @memberof Matrix3d
|
|
341
314
|
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
342
315
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
343
316
|
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
317
|
+
applyInverse(v) {
|
|
318
|
+
// invert the current matrix
|
|
319
|
+
let im = pool.pull("Matrix3d", this).invert();
|
|
347
320
|
|
|
348
|
-
|
|
349
|
-
|
|
321
|
+
// apply the inverted matrix
|
|
322
|
+
im.apply(v);
|
|
350
323
|
|
|
351
|
-
|
|
324
|
+
pool.push(im);
|
|
352
325
|
|
|
353
|
-
|
|
354
|
-
|
|
326
|
+
return v;
|
|
327
|
+
}
|
|
355
328
|
|
|
356
329
|
/**
|
|
357
330
|
* generate an orthogonal projection matrix, with the result replacing the current matrix
|
|
358
331
|
* <img src="images/glOrtho.gif"/><br>
|
|
359
|
-
* @name ortho
|
|
360
|
-
* @memberof Matrix3d
|
|
361
332
|
* @param {number} left - farthest left on the x-axis
|
|
362
333
|
* @param {number} right - farthest right on the x-axis
|
|
363
334
|
* @param {number} bottom - farthest down on the y-axis
|
|
@@ -394,8 +365,6 @@ import { EPSILON } from './math.js';
|
|
|
394
365
|
|
|
395
366
|
/**
|
|
396
367
|
* scale the matrix
|
|
397
|
-
* @name scale
|
|
398
|
-
* @memberof Matrix3d
|
|
399
368
|
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
400
369
|
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
401
370
|
* @param {number} [z=0] - a number representing the depth vector
|
|
@@ -424,8 +393,6 @@ import { EPSILON } from './math.js';
|
|
|
424
393
|
|
|
425
394
|
/**
|
|
426
395
|
* adds a 2D scaling transformation.
|
|
427
|
-
* @name scaleV
|
|
428
|
-
* @memberof Matrix3d
|
|
429
396
|
* @param {Vector2d|Vector3d} v - scaling vector
|
|
430
397
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
431
398
|
*/
|
|
@@ -435,8 +402,6 @@ import { EPSILON } from './math.js';
|
|
|
435
402
|
|
|
436
403
|
/**
|
|
437
404
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
438
|
-
* @name scaleX
|
|
439
|
-
* @memberof Matrix3d
|
|
440
405
|
* @param {number} x - x scaling vector
|
|
441
406
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
442
407
|
*/
|
|
@@ -446,8 +411,6 @@ import { EPSILON } from './math.js';
|
|
|
446
411
|
|
|
447
412
|
/**
|
|
448
413
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
449
|
-
* @name scaleY
|
|
450
|
-
* @memberof Matrix3d
|
|
451
414
|
* @param {number} y - y scaling vector
|
|
452
415
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
453
416
|
*/
|
|
@@ -457,8 +420,6 @@ import { EPSILON } from './math.js';
|
|
|
457
420
|
|
|
458
421
|
/**
|
|
459
422
|
* rotate this matrix (counter-clockwise) by the specified angle (in radians).
|
|
460
|
-
* @name rotate
|
|
461
|
-
* @memberof Matrix3d
|
|
462
423
|
* @param {number} angle - Rotation angle in radians.
|
|
463
424
|
* @param {Vector3d} v - the axis to rotate around
|
|
464
425
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
@@ -536,21 +497,11 @@ import { EPSILON } from './math.js';
|
|
|
536
497
|
|
|
537
498
|
/**
|
|
538
499
|
* translate the matrix position using the given vector
|
|
539
|
-
* @
|
|
540
|
-
* @
|
|
541
|
-
* @method
|
|
542
|
-
* @param {number} x - a number representing the abscissa of the vector.
|
|
543
|
-
* @param {number} [y=x] - a number representing the ordinate of the vector.
|
|
500
|
+
* @param {number|Vector2d|Vector3d} x - a number representing the abscissa of the vector, or a vector object
|
|
501
|
+
* @param {number} [y] - a number representing the ordinate of the vector.
|
|
544
502
|
* @param {number} [z=0] - a number representing the depth of the vector
|
|
545
503
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
546
504
|
*/
|
|
547
|
-
/**
|
|
548
|
-
* translate the matrix by a vector on the horizontal and vertical axis
|
|
549
|
-
* @name translateV
|
|
550
|
-
* @memberof Matrix3d
|
|
551
|
-
* @param {Vector2d|Vector3d} v - the vector to translate the matrix by
|
|
552
|
-
* @returns {Matrix3d} Reference to this object for method chaining
|
|
553
|
-
*/
|
|
554
505
|
translate() {
|
|
555
506
|
let a = this.val;
|
|
556
507
|
let _x, _y, _z;
|
|
@@ -577,8 +528,6 @@ import { EPSILON } from './math.js';
|
|
|
577
528
|
|
|
578
529
|
/**
|
|
579
530
|
* returns true if the matrix is an identity matrix.
|
|
580
|
-
* @name isIdentity
|
|
581
|
-
* @memberof Matrix3d
|
|
582
531
|
* @returns {boolean}
|
|
583
532
|
*/
|
|
584
533
|
isIdentity() {
|
|
@@ -606,8 +555,6 @@ import { EPSILON } from './math.js';
|
|
|
606
555
|
|
|
607
556
|
/**
|
|
608
557
|
* return true if the two matrices are identical
|
|
609
|
-
* @name equals
|
|
610
|
-
* @memberof Matrix3d
|
|
611
558
|
* @param {Matrix3d} m - the other matrix
|
|
612
559
|
* @returns {boolean} true if both are equals
|
|
613
560
|
*/
|
|
@@ -637,8 +584,6 @@ import { EPSILON } from './math.js';
|
|
|
637
584
|
|
|
638
585
|
/**
|
|
639
586
|
* Clone the Matrix
|
|
640
|
-
* @name clone
|
|
641
|
-
* @memberof Matrix3d
|
|
642
587
|
* @returns {Matrix3d}
|
|
643
588
|
*/
|
|
644
589
|
clone() {
|
|
@@ -647,8 +592,6 @@ import { EPSILON } from './math.js';
|
|
|
647
592
|
|
|
648
593
|
/**
|
|
649
594
|
* return an array representation of this Matrix
|
|
650
|
-
* @name toArray
|
|
651
|
-
* @memberof Matrix3d
|
|
652
595
|
* @returns {Float32Array}
|
|
653
596
|
*/
|
|
654
597
|
toArray() {
|
|
@@ -657,8 +600,6 @@ import { EPSILON } from './math.js';
|
|
|
657
600
|
|
|
658
601
|
/**
|
|
659
602
|
* convert the object to a string representation
|
|
660
|
-
* @name toString
|
|
661
|
-
* @memberof Matrix3d
|
|
662
603
|
* @returns {string}
|
|
663
604
|
*/
|
|
664
605
|
toString() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -14,7 +14,7 @@ import { clamp } from './math.js';
|
|
|
14
14
|
* A Vector2d object that provide notification by executing the given callback when the vector is changed.
|
|
15
15
|
* @augments Vector2d
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
class ObservableVector2d extends Vector2d {
|
|
18
18
|
/**
|
|
19
19
|
* @param {number} x - x value of the vector
|
|
20
20
|
* @param {number} y - y value of the vector
|
|
@@ -94,10 +94,10 @@ import { clamp } from './math.js';
|
|
|
94
94
|
this._x = ret.x;
|
|
95
95
|
this._y = ret.y;
|
|
96
96
|
} else {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
this._x = x;
|
|
98
|
+
this._y = y;
|
|
99
|
+
}
|
|
100
|
+
return this;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
@@ -409,7 +409,7 @@ import { clamp } from './math.js';
|
|
|
409
409
|
* @param {number} step - the maximum step per iteration (Negative values will push the vector away from the target)
|
|
410
410
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
411
411
|
*/
|
|
412
|
-
|
|
412
|
+
moveTowards(target, step) {
|
|
413
413
|
let angle = Math.atan2(target.y - this._y, target.x - this._x);
|
|
414
414
|
|
|
415
415
|
let distance = this.distance(target);
|