melonjs 15.2.1 → 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/README.md +1 -1
- 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 +75 -23
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +13 -11
- package/dist/melonjs.mjs/application/settings.js +37 -1
- 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 +37 -47
- 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 +5 -5
- 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 +31 -39
- 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 +13 -14
- package/dist/melonjs.mjs/state/state.js +4 -51
- package/dist/melonjs.mjs/system/device.js +51 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +46 -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 +5 -18
- package/dist/melonjs.mjs/video/renderer.js +17 -30
- 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 +5 -29
- 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 +62 -67
- package/dist/melonjs.module.js +1272 -1713
- package/dist/types/application/application.d.ts +32 -31
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +80 -16
- 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/level/tiled/TMXUtils.d.ts +4 -6
- 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 +10 -18
- 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/stage.d.ts +3 -2
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +16 -9
- package/dist/types/system/event.d.ts +40 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +16 -43
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +4 -38
- 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 +48 -84
- package/package.json +15 -15
- package/src/application/application.js +73 -21
- package/src/application/header.js +1 -1
- package/src/application/resize.js +11 -9
- package/src/application/settings.js +36 -0
- 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 +36 -46
- 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 +4 -4
- 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 +30 -38
- 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 +12 -13
- package/src/state/state.js +2 -61
- package/src/system/device.js +50 -9
- package/src/system/event.js +44 -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 +4 -17
- package/src/video/renderer.js +16 -29
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +7 -28
- 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 +61 -66
- /package/src/{text → renderable/text}/textstyle.js +0 -0
package/src/math/vector2.js
CHANGED
|
@@ -5,7 +5,7 @@ import pool from "./../system/pooling.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a generic 2D Vector Object
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
export default class Vector2d {
|
|
9
9
|
/**
|
|
10
10
|
* @param {number} [x=0] - x value of the vector
|
|
11
11
|
* @param {number} [y=0] - y value of the vector
|
|
@@ -35,8 +35,6 @@ import pool from "./../system/pooling.js";
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* set the Vector x and y properties to the given values<br>
|
|
38
|
-
* @name set
|
|
39
|
-
* @memberof Vector2d
|
|
40
38
|
* @param {number} x
|
|
41
39
|
* @param {number} y
|
|
42
40
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
@@ -71,8 +69,6 @@ import pool from "./../system/pooling.js";
|
|
|
71
69
|
|
|
72
70
|
/**
|
|
73
71
|
* set the Vector x and y properties to 0
|
|
74
|
-
* @name setZero
|
|
75
|
-
* @memberof Vector2d
|
|
76
72
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
77
73
|
*/
|
|
78
74
|
setZero() {
|
|
@@ -81,8 +77,6 @@ import pool from "./../system/pooling.js";
|
|
|
81
77
|
|
|
82
78
|
/**
|
|
83
79
|
* set the Vector x and y properties using the passed vector
|
|
84
|
-
* @name setV
|
|
85
|
-
* @memberof Vector2d
|
|
86
80
|
* @param {Vector2d} v
|
|
87
81
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
88
82
|
*/
|
|
@@ -92,8 +86,6 @@ import pool from "./../system/pooling.js";
|
|
|
92
86
|
|
|
93
87
|
/**
|
|
94
88
|
* Add the passed vector to this vector
|
|
95
|
-
* @name add
|
|
96
|
-
* @memberof Vector2d
|
|
97
89
|
* @param {Vector2d} v
|
|
98
90
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
99
91
|
*/
|
|
@@ -103,8 +95,6 @@ import pool from "./../system/pooling.js";
|
|
|
103
95
|
|
|
104
96
|
/**
|
|
105
97
|
* Substract the passed vector to this vector
|
|
106
|
-
* @name sub
|
|
107
|
-
* @memberof Vector2d
|
|
108
98
|
* @param {Vector2d} v
|
|
109
99
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
110
100
|
*/
|
|
@@ -114,8 +104,6 @@ import pool from "./../system/pooling.js";
|
|
|
114
104
|
|
|
115
105
|
/**
|
|
116
106
|
* Multiply this vector values by the given scalar
|
|
117
|
-
* @name scale
|
|
118
|
-
* @memberof Vector2d
|
|
119
107
|
* @param {number} x
|
|
120
108
|
* @param {number} [y=x]
|
|
121
109
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
@@ -126,8 +114,6 @@ import pool from "./../system/pooling.js";
|
|
|
126
114
|
|
|
127
115
|
/**
|
|
128
116
|
* Convert this vector into isometric coordinate space
|
|
129
|
-
* @name toIso
|
|
130
|
-
* @memberof Vector2d
|
|
131
117
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
132
118
|
*/
|
|
133
119
|
toIso() {
|
|
@@ -136,8 +122,6 @@ import pool from "./../system/pooling.js";
|
|
|
136
122
|
|
|
137
123
|
/**
|
|
138
124
|
* Convert this vector into 2d coordinate space
|
|
139
|
-
* @name to2d
|
|
140
|
-
* @memberof Vector2d
|
|
141
125
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
142
126
|
*/
|
|
143
127
|
to2d() {
|
|
@@ -146,8 +130,6 @@ import pool from "./../system/pooling.js";
|
|
|
146
130
|
|
|
147
131
|
/**
|
|
148
132
|
* Multiply this vector values by the passed vector
|
|
149
|
-
* @name scaleV
|
|
150
|
-
* @memberof Vector2d
|
|
151
133
|
* @param {Vector2d} v
|
|
152
134
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
153
135
|
*/
|
|
@@ -157,8 +139,6 @@ import pool from "./../system/pooling.js";
|
|
|
157
139
|
|
|
158
140
|
/**
|
|
159
141
|
* Divide this vector values by the passed value
|
|
160
|
-
* @name div
|
|
161
|
-
* @memberof Vector2d
|
|
162
142
|
* @param {number} n - the value to divide the vector by
|
|
163
143
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
164
144
|
*/
|
|
@@ -168,8 +148,6 @@ import pool from "./../system/pooling.js";
|
|
|
168
148
|
|
|
169
149
|
/**
|
|
170
150
|
* Update this vector values to absolute values
|
|
171
|
-
* @name abs
|
|
172
|
-
* @memberof Vector2d
|
|
173
151
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
174
152
|
*/
|
|
175
153
|
abs() {
|
|
@@ -178,8 +156,6 @@ import pool from "./../system/pooling.js";
|
|
|
178
156
|
|
|
179
157
|
/**
|
|
180
158
|
* Clamp the vector value within the specified value range
|
|
181
|
-
* @name clamp
|
|
182
|
-
* @memberof Vector2d
|
|
183
159
|
* @param {number} low
|
|
184
160
|
* @param {number} high
|
|
185
161
|
* @returns {Vector2d} new me.Vector2d
|
|
@@ -190,8 +166,6 @@ import pool from "./../system/pooling.js";
|
|
|
190
166
|
|
|
191
167
|
/**
|
|
192
168
|
* Clamp this vector value within the specified value range
|
|
193
|
-
* @name clampSelf
|
|
194
|
-
* @memberof Vector2d
|
|
195
169
|
* @param {number} low
|
|
196
170
|
* @param {number} high
|
|
197
171
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
@@ -202,8 +176,6 @@ import pool from "./../system/pooling.js";
|
|
|
202
176
|
|
|
203
177
|
/**
|
|
204
178
|
* Update this vector with the minimum value between this and the passed vector
|
|
205
|
-
* @name minV
|
|
206
|
-
* @memberof Vector2d
|
|
207
179
|
* @param {Vector2d} v
|
|
208
180
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
209
181
|
*/
|
|
@@ -213,8 +185,6 @@ import pool from "./../system/pooling.js";
|
|
|
213
185
|
|
|
214
186
|
/**
|
|
215
187
|
* Update this vector with the maximum value between this and the passed vector
|
|
216
|
-
* @name maxV
|
|
217
|
-
* @memberof Vector2d
|
|
218
188
|
* @param {Vector2d} v
|
|
219
189
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
220
190
|
*/
|
|
@@ -224,8 +194,6 @@ import pool from "./../system/pooling.js";
|
|
|
224
194
|
|
|
225
195
|
/**
|
|
226
196
|
* Floor the vector values
|
|
227
|
-
* @name floor
|
|
228
|
-
* @memberof Vector2d
|
|
229
197
|
* @returns {Vector2d} new me.Vector2d
|
|
230
198
|
*/
|
|
231
199
|
floor() {
|
|
@@ -234,8 +202,6 @@ import pool from "./../system/pooling.js";
|
|
|
234
202
|
|
|
235
203
|
/**
|
|
236
204
|
* Floor this vector values
|
|
237
|
-
* @name floorSelf
|
|
238
|
-
* @memberof Vector2d
|
|
239
205
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
240
206
|
*/
|
|
241
207
|
floorSelf() {
|
|
@@ -244,8 +210,6 @@ import pool from "./../system/pooling.js";
|
|
|
244
210
|
|
|
245
211
|
/**
|
|
246
212
|
* Ceil the vector values
|
|
247
|
-
* @name ceil
|
|
248
|
-
* @memberof Vector2d
|
|
249
213
|
* @returns {Vector2d} new me.Vector2d
|
|
250
214
|
*/
|
|
251
215
|
ceil() {
|
|
@@ -254,8 +218,6 @@ import pool from "./../system/pooling.js";
|
|
|
254
218
|
|
|
255
219
|
/**
|
|
256
220
|
* Ceil this vector values
|
|
257
|
-
* @name ceilSelf
|
|
258
|
-
* @memberof Vector2d
|
|
259
221
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
260
222
|
*/
|
|
261
223
|
ceilSelf() {
|
|
@@ -264,8 +226,6 @@ import pool from "./../system/pooling.js";
|
|
|
264
226
|
|
|
265
227
|
/**
|
|
266
228
|
* Negate the vector values
|
|
267
|
-
* @name negate
|
|
268
|
-
* @memberof Vector2d
|
|
269
229
|
* @returns {Vector2d} new me.Vector2d
|
|
270
230
|
*/
|
|
271
231
|
negate() {
|
|
@@ -274,8 +234,6 @@ import pool from "./../system/pooling.js";
|
|
|
274
234
|
|
|
275
235
|
/**
|
|
276
236
|
* Negate this vector values
|
|
277
|
-
* @name negateSelf
|
|
278
|
-
* @memberof Vector2d
|
|
279
237
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
280
238
|
*/
|
|
281
239
|
negateSelf() {
|
|
@@ -284,8 +242,6 @@ import pool from "./../system/pooling.js";
|
|
|
284
242
|
|
|
285
243
|
/**
|
|
286
244
|
* Copy the x,y values of the passed vector to this one
|
|
287
|
-
* @name copy
|
|
288
|
-
* @memberof Vector2d
|
|
289
245
|
* @param {Vector2d} v
|
|
290
246
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
291
247
|
*/
|
|
@@ -294,19 +250,9 @@ import pool from "./../system/pooling.js";
|
|
|
294
250
|
}
|
|
295
251
|
|
|
296
252
|
/**
|
|
297
|
-
* return true if
|
|
298
|
-
* @
|
|
299
|
-
* @
|
|
300
|
-
* @method
|
|
301
|
-
* @param {Vector2d} v
|
|
302
|
-
* @returns {boolean}
|
|
303
|
-
*/
|
|
304
|
-
/**
|
|
305
|
-
* return true if this vector is equal to the given values
|
|
306
|
-
* @name equals
|
|
307
|
-
* @memberof Vector2d
|
|
308
|
-
* @param {number} x
|
|
309
|
-
* @param {number} y
|
|
253
|
+
* return true if this vector is equal to the given values or vector
|
|
254
|
+
* @param {number|Vector2d|ObservableVector2d} x
|
|
255
|
+
* @param {number} [y]
|
|
310
256
|
* @returns {boolean}
|
|
311
257
|
*/
|
|
312
258
|
equals() {
|
|
@@ -325,8 +271,6 @@ import pool from "./../system/pooling.js";
|
|
|
325
271
|
|
|
326
272
|
/**
|
|
327
273
|
* normalize this vector (scale the vector so that its magnitude is 1)
|
|
328
|
-
* @name normalize
|
|
329
|
-
* @memberof Vector2d
|
|
330
274
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
331
275
|
*/
|
|
332
276
|
normalize() {
|
|
@@ -336,8 +280,6 @@ import pool from "./../system/pooling.js";
|
|
|
336
280
|
/**
|
|
337
281
|
* change this vector to be perpendicular to what it was before.<br>
|
|
338
282
|
* (Effectively rotates it 90 degrees in a clockwise direction)
|
|
339
|
-
* @name perp
|
|
340
|
-
* @memberof Vector2d
|
|
341
283
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
342
284
|
*/
|
|
343
285
|
perp() {
|
|
@@ -346,8 +288,6 @@ import pool from "./../system/pooling.js";
|
|
|
346
288
|
|
|
347
289
|
/**
|
|
348
290
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
349
|
-
* @name rotate
|
|
350
|
-
* @memberof Vector2d
|
|
351
291
|
* @param {number} angle - The angle to rotate (in radians)
|
|
352
292
|
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around
|
|
353
293
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
@@ -372,8 +312,6 @@ import pool from "./../system/pooling.js";
|
|
|
372
312
|
|
|
373
313
|
/**
|
|
374
314
|
* return the dot product of this vector and the passed one
|
|
375
|
-
* @name dot
|
|
376
|
-
* @memberof Vector2d
|
|
377
315
|
* @param {Vector2d} v
|
|
378
316
|
* @returns {number} The dot product.
|
|
379
317
|
*/
|
|
@@ -383,8 +321,6 @@ import pool from "./../system/pooling.js";
|
|
|
383
321
|
|
|
384
322
|
/**
|
|
385
323
|
* return the cross product of this vector and the passed one
|
|
386
|
-
* @name cross
|
|
387
|
-
* @memberof Vector2d
|
|
388
324
|
* @param {Vector2d} v
|
|
389
325
|
* @returns {number} The cross product.
|
|
390
326
|
*/
|
|
@@ -392,10 +328,8 @@ import pool from "./../system/pooling.js";
|
|
|
392
328
|
return this.x * v.y - this.y * v.x;
|
|
393
329
|
}
|
|
394
330
|
|
|
395
|
-
|
|
331
|
+
/**
|
|
396
332
|
* return the square length of this vector
|
|
397
|
-
* @name length2
|
|
398
|
-
* @memberof Vector2d
|
|
399
333
|
* @returns {number} The length^2 of this vector.
|
|
400
334
|
*/
|
|
401
335
|
length2() {
|
|
@@ -404,8 +338,6 @@ import pool from "./../system/pooling.js";
|
|
|
404
338
|
|
|
405
339
|
/**
|
|
406
340
|
* return the length (magnitude) of this vector
|
|
407
|
-
* @name length
|
|
408
|
-
* @memberof Vector2d
|
|
409
341
|
* @returns {number} the length of this vector
|
|
410
342
|
*/
|
|
411
343
|
length() {
|
|
@@ -414,8 +346,6 @@ import pool from "./../system/pooling.js";
|
|
|
414
346
|
|
|
415
347
|
/**
|
|
416
348
|
* Linearly interpolate between this vector and the given one.
|
|
417
|
-
* @name lerp
|
|
418
|
-
* @memberof Vector2d
|
|
419
349
|
* @param {Vector2d} v
|
|
420
350
|
* @param {number} alpha - distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
421
351
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
@@ -428,13 +358,11 @@ import pool from "./../system/pooling.js";
|
|
|
428
358
|
|
|
429
359
|
/**
|
|
430
360
|
* interpolate the position of this vector towards the given one by the given maximum step.
|
|
431
|
-
* @name moveTowards
|
|
432
|
-
* @memberof Vector2d
|
|
433
361
|
* @param {Vector2d} target
|
|
434
362
|
* @param {number} step - the maximum step per iteration (Negative values will push the vector away from the target)
|
|
435
363
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
436
364
|
*/
|
|
437
|
-
|
|
365
|
+
moveTowards(target, step) {
|
|
438
366
|
let angle = Math.atan2(target.y - this.y, target.x - this.x);
|
|
439
367
|
|
|
440
368
|
let distance = this.distance(target);
|
|
@@ -451,8 +379,6 @@ import pool from "./../system/pooling.js";
|
|
|
451
379
|
|
|
452
380
|
/**
|
|
453
381
|
* return the distance between this vector and the passed one
|
|
454
|
-
* @name distance
|
|
455
|
-
* @memberof Vector2d
|
|
456
382
|
* @param {Vector2d} v
|
|
457
383
|
* @returns {number}
|
|
458
384
|
*/
|
|
@@ -463,8 +389,6 @@ import pool from "./../system/pooling.js";
|
|
|
463
389
|
|
|
464
390
|
/**
|
|
465
391
|
* return the angle between this vector and the passed one
|
|
466
|
-
* @name angle
|
|
467
|
-
* @memberof Vector2d
|
|
468
392
|
* @param {Vector2d} v
|
|
469
393
|
* @returns {number} angle in radians
|
|
470
394
|
*/
|
|
@@ -474,8 +398,6 @@ import pool from "./../system/pooling.js";
|
|
|
474
398
|
|
|
475
399
|
/**
|
|
476
400
|
* project this vector on to another vector.
|
|
477
|
-
* @name project
|
|
478
|
-
* @memberof Vector2d
|
|
479
401
|
* @param {Vector2d} v - The vector to project onto.
|
|
480
402
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
481
403
|
*/
|
|
@@ -486,8 +408,6 @@ import pool from "./../system/pooling.js";
|
|
|
486
408
|
/**
|
|
487
409
|
* Project this vector onto a vector of unit length.<br>
|
|
488
410
|
* This is slightly more efficient than `project` when dealing with unit vectors.
|
|
489
|
-
* @name projectN
|
|
490
|
-
* @memberof Vector2d
|
|
491
411
|
* @param {Vector2d} v - The unit vector to project onto.
|
|
492
412
|
* @returns {Vector2d} Reference to this object for method chaining
|
|
493
413
|
*/
|
|
@@ -497,8 +417,6 @@ import pool from "./../system/pooling.js";
|
|
|
497
417
|
|
|
498
418
|
/**
|
|
499
419
|
* return a clone copy of this vector
|
|
500
|
-
* @name clone
|
|
501
|
-
* @memberof Vector2d
|
|
502
420
|
* @returns {Vector2d} new me.Vector2d
|
|
503
421
|
*/
|
|
504
422
|
clone() {
|
|
@@ -507,8 +425,6 @@ import pool from "./../system/pooling.js";
|
|
|
507
425
|
|
|
508
426
|
/**
|
|
509
427
|
* convert the object to a string representation
|
|
510
|
-
* @name toString
|
|
511
|
-
* @memberof Vector2d
|
|
512
428
|
* @returns {string}
|
|
513
429
|
*/
|
|
514
430
|
toString() {
|
package/src/math/vector3.js
CHANGED
|
@@ -5,7 +5,7 @@ import pool from "./../system/pooling.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a generic 3D Vector Object
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
export default class Vector3d {
|
|
9
9
|
/**
|
|
10
10
|
* @param {number} [x=0] - x value of the vector
|
|
11
11
|
* @param {number} [y=0] - y value of the vector
|
|
@@ -38,8 +38,6 @@ import pool from "./../system/pooling.js";
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* set the Vector x and y properties to the given values<br>
|
|
41
|
-
* @name set
|
|
42
|
-
* @memberof Vector3d
|
|
43
41
|
* @param {number} x
|
|
44
42
|
* @param {number} y
|
|
45
43
|
* @param {number} [z=0]
|
|
@@ -84,8 +82,6 @@ import pool from "./../system/pooling.js";
|
|
|
84
82
|
|
|
85
83
|
/**
|
|
86
84
|
* set the Vector x and y properties to 0
|
|
87
|
-
* @name setZero
|
|
88
|
-
* @memberof Vector3d
|
|
89
85
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
90
86
|
*/
|
|
91
87
|
setZero() {
|
|
@@ -94,8 +90,6 @@ import pool from "./../system/pooling.js";
|
|
|
94
90
|
|
|
95
91
|
/**
|
|
96
92
|
* set the Vector x and y properties using the passed vector
|
|
97
|
-
* @name setV
|
|
98
|
-
* @memberof Vector3d
|
|
99
93
|
* @param {Vector2d|Vector3d} v
|
|
100
94
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
101
95
|
*/
|
|
@@ -105,8 +99,6 @@ import pool from "./../system/pooling.js";
|
|
|
105
99
|
|
|
106
100
|
/**
|
|
107
101
|
* Add the passed vector to this vector
|
|
108
|
-
* @name add
|
|
109
|
-
* @memberof Vector3d
|
|
110
102
|
* @param {Vector2d|Vector3d} v
|
|
111
103
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
112
104
|
*/
|
|
@@ -116,8 +108,6 @@ import pool from "./../system/pooling.js";
|
|
|
116
108
|
|
|
117
109
|
/**
|
|
118
110
|
* Substract the passed vector to this vector
|
|
119
|
-
* @name sub
|
|
120
|
-
* @memberof Vector3d
|
|
121
111
|
* @param {Vector2d|Vector3d} v
|
|
122
112
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
123
113
|
*/
|
|
@@ -127,8 +117,6 @@ import pool from "./../system/pooling.js";
|
|
|
127
117
|
|
|
128
118
|
/**
|
|
129
119
|
* Multiply this vector values by the given scalar
|
|
130
|
-
* @name scale
|
|
131
|
-
* @memberof Vector3d
|
|
132
120
|
* @param {number} x
|
|
133
121
|
* @param {number} [y=x]
|
|
134
122
|
* @param {number} [z=1]
|
|
@@ -140,8 +128,6 @@ import pool from "./../system/pooling.js";
|
|
|
140
128
|
|
|
141
129
|
/**
|
|
142
130
|
* Multiply this vector values by the passed vector
|
|
143
|
-
* @name scaleV
|
|
144
|
-
* @memberof Vector3d
|
|
145
131
|
* @param {Vector2d|Vector3d} v
|
|
146
132
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
147
133
|
*/
|
|
@@ -151,8 +137,6 @@ import pool from "./../system/pooling.js";
|
|
|
151
137
|
|
|
152
138
|
/**
|
|
153
139
|
* Convert this vector into isometric coordinate space
|
|
154
|
-
* @name toIso
|
|
155
|
-
* @memberof Vector3d
|
|
156
140
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
157
141
|
*/
|
|
158
142
|
toIso() {
|
|
@@ -161,8 +145,6 @@ import pool from "./../system/pooling.js";
|
|
|
161
145
|
|
|
162
146
|
/**
|
|
163
147
|
* Convert this vector into 2d coordinate space
|
|
164
|
-
* @name to2d
|
|
165
|
-
* @memberof Vector3d
|
|
166
148
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
167
149
|
*/
|
|
168
150
|
to2d() {
|
|
@@ -171,8 +153,6 @@ import pool from "./../system/pooling.js";
|
|
|
171
153
|
|
|
172
154
|
/**
|
|
173
155
|
* Divide this vector values by the passed value
|
|
174
|
-
* @name div
|
|
175
|
-
* @memberof Vector3d
|
|
176
156
|
* @param {number} n - the value to divide the vector by
|
|
177
157
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
178
158
|
*/
|
|
@@ -182,8 +162,6 @@ import pool from "./../system/pooling.js";
|
|
|
182
162
|
|
|
183
163
|
/**
|
|
184
164
|
* Update this vector values to absolute values
|
|
185
|
-
* @name abs
|
|
186
|
-
* @memberof Vector3d
|
|
187
165
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
188
166
|
*/
|
|
189
167
|
abs() {
|
|
@@ -192,8 +170,6 @@ import pool from "./../system/pooling.js";
|
|
|
192
170
|
|
|
193
171
|
/**
|
|
194
172
|
* Clamp the vector value within the specified value range
|
|
195
|
-
* @name clamp
|
|
196
|
-
* @memberof Vector3d
|
|
197
173
|
* @param {number} low
|
|
198
174
|
* @param {number} high
|
|
199
175
|
* @returns {Vector3d} new me.Vector3d
|
|
@@ -204,8 +180,6 @@ import pool from "./../system/pooling.js";
|
|
|
204
180
|
|
|
205
181
|
/**
|
|
206
182
|
* Clamp this vector value within the specified value range
|
|
207
|
-
* @name clampSelf
|
|
208
|
-
* @memberof Vector3d
|
|
209
183
|
* @param {number} low
|
|
210
184
|
* @param {number} high
|
|
211
185
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
@@ -216,8 +190,6 @@ import pool from "./../system/pooling.js";
|
|
|
216
190
|
|
|
217
191
|
/**
|
|
218
192
|
* Update this vector with the minimum value between this and the passed vector
|
|
219
|
-
* @name minV
|
|
220
|
-
* @memberof Vector3d
|
|
221
193
|
* @param {Vector2d|Vector3d} v
|
|
222
194
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
223
195
|
*/
|
|
@@ -228,8 +200,6 @@ import pool from "./../system/pooling.js";
|
|
|
228
200
|
|
|
229
201
|
/**
|
|
230
202
|
* Update this vector with the maximum value between this and the passed vector
|
|
231
|
-
* @name maxV
|
|
232
|
-
* @memberof Vector3d
|
|
233
203
|
* @param {Vector2d|Vector3d} v
|
|
234
204
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
235
205
|
*/
|
|
@@ -240,8 +210,6 @@ import pool from "./../system/pooling.js";
|
|
|
240
210
|
|
|
241
211
|
/**
|
|
242
212
|
* Floor the vector values
|
|
243
|
-
* @name floor
|
|
244
|
-
* @memberof Vector3d
|
|
245
213
|
* @returns {Vector3d} new me.Vector3d
|
|
246
214
|
*/
|
|
247
215
|
floor() {
|
|
@@ -250,8 +218,6 @@ import pool from "./../system/pooling.js";
|
|
|
250
218
|
|
|
251
219
|
/**
|
|
252
220
|
* Floor this vector values
|
|
253
|
-
* @name floorSelf
|
|
254
|
-
* @memberof Vector3d
|
|
255
221
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
256
222
|
*/
|
|
257
223
|
floorSelf() {
|
|
@@ -260,8 +226,6 @@ import pool from "./../system/pooling.js";
|
|
|
260
226
|
|
|
261
227
|
/**
|
|
262
228
|
* Ceil the vector values
|
|
263
|
-
* @name ceil
|
|
264
|
-
* @memberof Vector3d
|
|
265
229
|
* @returns {Vector3d} new me.Vector3d
|
|
266
230
|
*/
|
|
267
231
|
ceil() {
|
|
@@ -270,8 +234,6 @@ import pool from "./../system/pooling.js";
|
|
|
270
234
|
|
|
271
235
|
/**
|
|
272
236
|
* Ceil this vector values
|
|
273
|
-
* @name ceilSelf
|
|
274
|
-
* @memberof Vector3d
|
|
275
237
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
276
238
|
*/
|
|
277
239
|
ceilSelf() {
|
|
@@ -280,8 +242,6 @@ import pool from "./../system/pooling.js";
|
|
|
280
242
|
|
|
281
243
|
/**
|
|
282
244
|
* Negate the vector values
|
|
283
|
-
* @name negate
|
|
284
|
-
* @memberof Vector3d
|
|
285
245
|
* @returns {Vector3d} new me.Vector3d
|
|
286
246
|
*/
|
|
287
247
|
negate() {
|
|
@@ -290,8 +250,6 @@ import pool from "./../system/pooling.js";
|
|
|
290
250
|
|
|
291
251
|
/**
|
|
292
252
|
* Negate this vector values
|
|
293
|
-
* @name negateSelf
|
|
294
|
-
* @memberof Vector3d
|
|
295
253
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
296
254
|
*/
|
|
297
255
|
negateSelf() {
|
|
@@ -300,8 +258,6 @@ import pool from "./../system/pooling.js";
|
|
|
300
258
|
|
|
301
259
|
/**
|
|
302
260
|
* Copy the components of the given vector into this one
|
|
303
|
-
* @name copy
|
|
304
|
-
* @memberof Vector3d
|
|
305
261
|
* @param {Vector2d|Vector3d} v
|
|
306
262
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
307
263
|
*/
|
|
@@ -310,19 +266,9 @@ import pool from "./../system/pooling.js";
|
|
|
310
266
|
}
|
|
311
267
|
|
|
312
268
|
/**
|
|
313
|
-
* return true if
|
|
314
|
-
* @
|
|
315
|
-
* @
|
|
316
|
-
* @method
|
|
317
|
-
* @param {Vector2d|Vector3d} v
|
|
318
|
-
* @returns {boolean}
|
|
319
|
-
*/
|
|
320
|
-
/**
|
|
321
|
-
* return true if this vector is equal to the given values
|
|
322
|
-
* @name equals
|
|
323
|
-
* @memberof Vector3d
|
|
324
|
-
* @param {number} x
|
|
325
|
-
* @param {number} y
|
|
269
|
+
* return true if this vector is equal to the given values or vector
|
|
270
|
+
* @param {number|Vector2d|ObservableVector2d|Vector3d|ObservableVector3d} x
|
|
271
|
+
* @param {number} [y]
|
|
326
272
|
* @param {number} [z]
|
|
327
273
|
* @returns {boolean}
|
|
328
274
|
*/
|
|
@@ -349,8 +295,6 @@ import pool from "./../system/pooling.js";
|
|
|
349
295
|
|
|
350
296
|
/**
|
|
351
297
|
* normalize this vector (scale the vector so that its magnitude is 1)
|
|
352
|
-
* @name normalize
|
|
353
|
-
* @memberof Vector3d
|
|
354
298
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
355
299
|
*/
|
|
356
300
|
normalize() {
|
|
@@ -360,8 +304,6 @@ import pool from "./../system/pooling.js";
|
|
|
360
304
|
/**
|
|
361
305
|
* change this vector to be perpendicular to what it was before.<br>
|
|
362
306
|
* (Effectively rotates it 90 degrees in a clockwise direction around the z axis)
|
|
363
|
-
* @name perp
|
|
364
|
-
* @memberof Vector3d
|
|
365
307
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
366
308
|
*/
|
|
367
309
|
perp() {
|
|
@@ -370,8 +312,6 @@ import pool from "./../system/pooling.js";
|
|
|
370
312
|
|
|
371
313
|
/**
|
|
372
314
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis
|
|
373
|
-
* @name rotate
|
|
374
|
-
* @memberof Vector3d
|
|
375
315
|
* @param {number} angle - The angle to rotate (in radians)
|
|
376
316
|
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around (on the same z axis)
|
|
377
317
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
@@ -397,8 +337,6 @@ import pool from "./../system/pooling.js";
|
|
|
397
337
|
|
|
398
338
|
/**
|
|
399
339
|
* return the dot product of this vector and the passed one
|
|
400
|
-
* @name dot
|
|
401
|
-
* @memberof Vector3d
|
|
402
340
|
* @param {Vector2d|Vector3d} v
|
|
403
341
|
* @returns {number} The dot product.
|
|
404
342
|
*/
|
|
@@ -408,8 +346,6 @@ import pool from "./../system/pooling.js";
|
|
|
408
346
|
|
|
409
347
|
/**
|
|
410
348
|
* calculate the cross product of this vector and the passed one
|
|
411
|
-
* @name cross
|
|
412
|
-
* @memberof Vector3d
|
|
413
349
|
* @param {Vector3d} v
|
|
414
350
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
415
351
|
*/
|
|
@@ -424,10 +360,8 @@ import pool from "./../system/pooling.js";
|
|
|
424
360
|
return this;
|
|
425
361
|
}
|
|
426
362
|
|
|
427
|
-
|
|
363
|
+
/**
|
|
428
364
|
* return the square length of this vector
|
|
429
|
-
* @name length2
|
|
430
|
-
* @memberof Vector3d
|
|
431
365
|
* @returns {number} The length^2 of this vector.
|
|
432
366
|
*/
|
|
433
367
|
length2() {
|
|
@@ -436,8 +370,6 @@ import pool from "./../system/pooling.js";
|
|
|
436
370
|
|
|
437
371
|
/**
|
|
438
372
|
* return the length (magnitude) of this vector
|
|
439
|
-
* @name length
|
|
440
|
-
* @memberof Vector3d
|
|
441
373
|
* @returns {number} the length of this vector
|
|
442
374
|
*/
|
|
443
375
|
length() {
|
|
@@ -446,8 +378,6 @@ import pool from "./../system/pooling.js";
|
|
|
446
378
|
|
|
447
379
|
/**
|
|
448
380
|
* Linearly interpolate between this vector and the given one.
|
|
449
|
-
* @name lerp
|
|
450
|
-
* @memberof Vector3d
|
|
451
381
|
* @param {Vector3d} v
|
|
452
382
|
* @param {number} alpha - distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
453
383
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
@@ -461,8 +391,6 @@ import pool from "./../system/pooling.js";
|
|
|
461
391
|
|
|
462
392
|
/**
|
|
463
393
|
* interpolate the position of this vector on the x and y axis towards the given one by the given maximum step.
|
|
464
|
-
* @name moveTowards
|
|
465
|
-
* @memberof Vector3d
|
|
466
394
|
* @param {Vector2d|Vector3d} target
|
|
467
395
|
* @param {number} step - the maximum step per iteration (Negative values will push the vector away from the target)
|
|
468
396
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
@@ -487,8 +415,6 @@ import pool from "./../system/pooling.js";
|
|
|
487
415
|
|
|
488
416
|
/**
|
|
489
417
|
* return the distance between this vector and the passed one
|
|
490
|
-
* @name distance
|
|
491
|
-
* @memberof Vector3d
|
|
492
418
|
* @param {Vector2d|Vector3d} v
|
|
493
419
|
* @returns {number}
|
|
494
420
|
*/
|
|
@@ -501,8 +427,6 @@ import pool from "./../system/pooling.js";
|
|
|
501
427
|
|
|
502
428
|
/**
|
|
503
429
|
* return the angle between this vector and the passed one
|
|
504
|
-
* @name angle
|
|
505
|
-
* @memberof Vector3d
|
|
506
430
|
* @param {Vector2d|Vector3d} v
|
|
507
431
|
* @returns {number} angle in radians
|
|
508
432
|
*/
|
|
@@ -512,8 +436,6 @@ import pool from "./../system/pooling.js";
|
|
|
512
436
|
|
|
513
437
|
/**
|
|
514
438
|
* project this vector on to another vector.
|
|
515
|
-
* @name project
|
|
516
|
-
* @memberof Vector3d
|
|
517
439
|
* @param {Vector2d|Vector3d} v - The vector to project onto.
|
|
518
440
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
519
441
|
*/
|
|
@@ -525,8 +447,6 @@ import pool from "./../system/pooling.js";
|
|
|
525
447
|
/**
|
|
526
448
|
* Project this vector onto a vector of unit length.<br>
|
|
527
449
|
* This is slightly more efficient than `project` when dealing with unit vectors.
|
|
528
|
-
* @name projectN
|
|
529
|
-
* @memberof Vector3d
|
|
530
450
|
* @param {Vector2d|Vector3d} v - The unit vector to project onto.
|
|
531
451
|
* @returns {Vector3d} Reference to this object for method chaining
|
|
532
452
|
*/
|
|
@@ -537,8 +457,6 @@ import pool from "./../system/pooling.js";
|
|
|
537
457
|
|
|
538
458
|
/**
|
|
539
459
|
* return a clone copy of this vector
|
|
540
|
-
* @name clone
|
|
541
|
-
* @memberof Vector3d
|
|
542
460
|
* @returns {Vector3d} new me.Vector3d
|
|
543
461
|
*/
|
|
544
462
|
clone() {
|
|
@@ -547,8 +465,6 @@ import pool from "./../system/pooling.js";
|
|
|
547
465
|
|
|
548
466
|
/**
|
|
549
467
|
* convert the object to a string representation
|
|
550
|
-
* @name toString
|
|
551
|
-
* @memberof Vector3d
|
|
552
468
|
* @returns {string}
|
|
553
469
|
*/
|
|
554
470
|
toString() {
|