melonjs 14.0.2 → 14.1.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.
- package/README.md +2 -0
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +10 -0
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/earcut.js +10 -0
- package/dist/melonjs.mjs/_virtual/howler.js +10 -0
- package/dist/melonjs.mjs/_virtual/index.js +10 -0
- package/dist/melonjs.mjs/_virtual/index2.js +10 -0
- package/dist/melonjs.mjs/_virtual/multimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/setmultimap.js +10 -0
- package/dist/melonjs.mjs/application/application.js +238 -0
- package/dist/melonjs.mjs/audio/audio.js +536 -0
- package/dist/melonjs.mjs/camera/camera2d.js +731 -0
- package/dist/melonjs.mjs/entity/entity.js +247 -0
- package/dist/melonjs.mjs/game.js +29 -0
- package/dist/melonjs.mjs/geometries/ellipse.js +274 -0
- package/dist/melonjs.mjs/geometries/line.js +115 -0
- package/dist/melonjs.mjs/geometries/path2d.js +318 -0
- package/dist/melonjs.mjs/geometries/point.js +88 -0
- package/dist/melonjs.mjs/geometries/poly.js +498 -0
- package/dist/melonjs.mjs/geometries/rectangle.js +374 -0
- package/dist/melonjs.mjs/geometries/roundrect.js +167 -0
- package/dist/melonjs.mjs/index.js +248 -0
- package/dist/melonjs.mjs/input/gamepad.js +501 -0
- package/dist/melonjs.mjs/input/input.js +26 -0
- package/dist/melonjs.mjs/input/keyboard.js +470 -0
- package/dist/melonjs.mjs/input/pointer.js +393 -0
- package/dist/melonjs.mjs/input/pointerevent.js +818 -0
- package/dist/melonjs.mjs/lang/deprecated.js +157 -0
- package/dist/melonjs.mjs/level/level.js +297 -0
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +141 -0
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +446 -0
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +193 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +636 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +309 -0
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +81 -0
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +504 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +218 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +155 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +124 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +107 -0
- package/dist/melonjs.mjs/loader/loader.js +801 -0
- package/dist/melonjs.mjs/loader/loadingscreen.js +120 -0
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +11 -0
- package/dist/melonjs.mjs/math/color.js +616 -0
- package/dist/melonjs.mjs/math/math.js +218 -0
- package/dist/melonjs.mjs/math/matrix2.js +501 -0
- package/dist/melonjs.mjs/math/matrix3.js +679 -0
- package/dist/melonjs.mjs/math/observable_vector2.js +469 -0
- package/dist/melonjs.mjs/math/observable_vector3.js +559 -0
- package/dist/melonjs.mjs/math/vector2.js +526 -0
- package/dist/melonjs.mjs/math/vector3.js +567 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +73 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +21 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +324 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +69 -0
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +691 -0
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +350 -0
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3241 -0
- package/dist/melonjs.mjs/particles/emitter.js +265 -0
- package/dist/melonjs.mjs/particles/particle.js +186 -0
- package/dist/melonjs.mjs/particles/settings.js +319 -0
- package/dist/melonjs.mjs/physics/body.js +702 -0
- package/dist/melonjs.mjs/physics/bounds.js +459 -0
- package/dist/melonjs.mjs/physics/collision.js +132 -0
- package/dist/melonjs.mjs/physics/detector.js +194 -0
- package/dist/melonjs.mjs/physics/quadtree.js +394 -0
- package/dist/melonjs.mjs/physics/response.js +57 -0
- package/dist/melonjs.mjs/physics/sat.js +483 -0
- package/dist/melonjs.mjs/physics/world.js +219 -0
- package/dist/melonjs.mjs/plugin/plugin.js +141 -0
- package/dist/melonjs.mjs/renderable/collectable.js +60 -0
- package/dist/melonjs.mjs/renderable/colorlayer.js +78 -0
- package/dist/melonjs.mjs/renderable/container.js +1016 -0
- package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
- package/dist/melonjs.mjs/renderable/imagelayer.js +305 -0
- package/dist/melonjs.mjs/renderable/light2d.js +155 -0
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +246 -0
- package/dist/melonjs.mjs/renderable/renderable.js +781 -0
- package/dist/melonjs.mjs/renderable/sprite.js +653 -0
- package/dist/melonjs.mjs/renderable/trigger.js +156 -0
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +212 -0
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +225 -0
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +127 -0
- package/dist/melonjs.mjs/state/stage.js +236 -0
- package/dist/melonjs.mjs/state/state.js +596 -0
- package/dist/melonjs.mjs/system/device.js +909 -0
- package/dist/melonjs.mjs/system/dom.js +78 -0
- package/dist/melonjs.mjs/system/event.js +537 -0
- package/dist/melonjs.mjs/system/platform.js +41 -0
- package/dist/melonjs.mjs/system/pooling.js +209 -0
- package/dist/melonjs.mjs/system/save.js +157 -0
- package/dist/melonjs.mjs/system/timer.js +286 -0
- package/dist/melonjs.mjs/text/bitmaptext.js +363 -0
- package/dist/melonjs.mjs/text/bitmaptextdata.js +198 -0
- package/dist/melonjs.mjs/text/glyph.js +65 -0
- package/dist/melonjs.mjs/text/text.js +452 -0
- package/dist/melonjs.mjs/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/text/textstyle.js +23 -0
- package/dist/melonjs.mjs/tweens/easing.js +336 -0
- package/dist/melonjs.mjs/tweens/interpolation.js +112 -0
- package/dist/melonjs.mjs/tweens/tween.js +479 -0
- package/dist/melonjs.mjs/utils/agent.js +76 -0
- package/dist/melonjs.mjs/utils/array.js +63 -0
- package/dist/melonjs.mjs/utils/file.js +42 -0
- package/dist/melonjs.mjs/utils/function.js +70 -0
- package/dist/melonjs.mjs/utils/string.js +82 -0
- package/dist/melonjs.mjs/utils/utils.js +173 -0
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +806 -0
- package/dist/melonjs.mjs/video/renderer.js +410 -0
- package/dist/melonjs.mjs/video/texture/atlas.js +519 -0
- package/dist/melonjs.mjs/video/texture/cache.js +143 -0
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +144 -0
- package/dist/melonjs.mjs/video/video.js +462 -0
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +142 -0
- package/dist/melonjs.mjs/video/webgl/glshader.js +167 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -0
- package/dist/melonjs.mjs/video/webgl/utils/program.js +67 -0
- package/dist/melonjs.mjs/video/webgl/utils/string.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +92 -0
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +494 -0
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1035 -0
- package/dist/melonjs.module.d.ts +1298 -1359
- package/dist/melonjs.module.js +2072 -3520
- package/package.json +21 -16
- package/src/application/application.js +4 -5
- package/src/audio/audio.js +32 -32
- package/src/camera/camera2d.js +32 -33
- package/src/entity/entity.js +18 -19
- package/src/geometries/ellipse.js +17 -18
- package/src/geometries/line.js +6 -7
- package/src/geometries/path2d.js +33 -34
- package/src/geometries/point.js +1 -2
- package/src/geometries/poly.js +16 -18
- package/src/geometries/rectangle.js +19 -20
- package/src/geometries/roundrect.js +9 -10
- package/src/input/gamepad.js +15 -15
- package/src/input/keyboard.js +12 -12
- package/src/input/pointer.js +6 -6
- package/src/input/pointerevent.js +12 -12
- package/src/lang/deprecated.js +12 -12
- package/src/level/level.js +25 -25
- package/src/level/tiled/TMXLayer.js +23 -24
- package/src/level/tiled/TMXTile.js +6 -7
- package/src/level/tiled/TMXTileMap.js +8 -10
- package/src/level/tiled/TMXTileset.js +3 -4
- package/src/level/tiled/TMXTilesetGroup.js +1 -2
- package/src/level/tiled/TMXUtils.js +5 -5
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +20 -21
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -2
- package/src/loader/loader.js +20 -20
- package/src/math/color.js +21 -22
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +17 -18
- package/src/math/matrix3.js +26 -27
- package/src/math/observable_vector2.js +15 -16
- package/src/math/observable_vector3.js +17 -18
- package/src/math/vector2.js +10 -11
- package/src/math/vector3.js +11 -12
- package/src/particles/emitter.js +7 -8
- package/src/particles/particle.js +3 -4
- package/src/physics/body.js +29 -30
- package/src/physics/bounds.js +10 -10
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +6 -6
- package/src/physics/quadtree.js +18 -23
- package/src/physics/sat.js +31 -31
- package/src/physics/world.js +6 -7
- package/src/plugin/plugin.js +5 -5
- package/src/renderable/collectable.js +4 -6
- package/src/renderable/colorlayer.js +6 -8
- package/src/renderable/container.js +25 -27
- package/src/renderable/dragndrop.js +14 -14
- package/src/renderable/imagelayer.js +14 -15
- package/src/renderable/light2d.js +4 -5
- package/src/renderable/nineslicesprite.js +17 -18
- package/src/renderable/renderable.js +26 -28
- package/src/renderable/sprite.js +29 -30
- package/src/renderable/trigger.js +16 -17
- package/src/renderable/ui/uibaseelement.js +8 -9
- package/src/renderable/ui/uispriteelement.js +8 -8
- package/src/renderable/ui/uitextbutton.js +15 -15
- package/src/state/stage.js +8 -9
- package/src/state/state.js +17 -17
- package/src/system/device.js +11 -11
- package/src/system/event.js +10 -10
- package/src/system/pooling.js +9 -9
- package/src/system/save.js +2 -2
- package/src/system/timer.js +10 -10
- package/src/text/bitmaptext.js +19 -20
- package/src/text/bitmaptextdata.js +3 -4
- package/src/text/glyph.js +1 -2
- package/src/text/text.js +24 -25
- package/src/text/textmetrics.js +9 -10
- package/src/tweens/tween.js +20 -21
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +2 -2
- package/src/utils/function.js +6 -6
- package/src/utils/string.js +5 -5
- package/src/utils/utils.js +4 -4
- package/src/video/canvas/canvas_renderer.js +72 -73
- package/src/video/renderer.js +27 -28
- package/src/video/texture/atlas.js +22 -22
- package/src/video/texture/canvas_texture.js +9 -9
- package/src/video/video.js +17 -17
- package/src/video/webgl/buffer/vertex.js +1 -2
- package/src/video/webgl/glshader.js +12 -12
- package/src/video/webgl/webgl_compositor.js +42 -43
- package/src/video/webgl/webgl_renderer.js +76 -77
package/src/math/color.js
CHANGED
|
@@ -182,12 +182,12 @@ var cssToRGB = new Map();
|
|
|
182
182
|
* @classdesc
|
|
183
183
|
* A color manipulation object.
|
|
184
184
|
*/
|
|
185
|
-
class Color {
|
|
185
|
+
export default class Color {
|
|
186
186
|
/**
|
|
187
|
-
* @param {number} [r=0] red component or array of color components
|
|
188
|
-
* @param {number} [g=0] green component
|
|
189
|
-
* @param {number} [b=0] blue component
|
|
190
|
-
* @param {number} [alpha=1.0] alpha value
|
|
187
|
+
* @param {number} [r=0] - red component or array of color components
|
|
188
|
+
* @param {number} [g=0] - green component
|
|
189
|
+
* @param {number} [b=0] - blue component
|
|
190
|
+
* @param {number} [alpha=1.0] - alpha value
|
|
191
191
|
*/
|
|
192
192
|
constructor(r = 0, g = 0, b = 0, alpha = 1.0) {
|
|
193
193
|
this.onResetEvent(r, g, b, alpha);
|
|
@@ -257,10 +257,10 @@ class Color {
|
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
259
|
* Set this color to the specified value.
|
|
260
|
-
* @param {number} r red component [0 .. 255]
|
|
261
|
-
* @param {number} g green component [0 .. 255]
|
|
262
|
-
* @param {number} b blue component [0 .. 255]
|
|
263
|
-
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
260
|
+
* @param {number} r - red component [0 .. 255]
|
|
261
|
+
* @param {number} g - green component [0 .. 255]
|
|
262
|
+
* @param {number} b - blue component [0 .. 255]
|
|
263
|
+
* @param {number} [alpha=1.0] - alpha value [0.0 .. 1.0]
|
|
264
264
|
* @returns {Color} Reference to this object for method chaining
|
|
265
265
|
*/
|
|
266
266
|
setColor(r, g, b, alpha = 1.0) {
|
|
@@ -273,9 +273,9 @@ class Color {
|
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
275
|
* set this color to the specified HSV value
|
|
276
|
-
* @param {number} h hue (a value from 0 to 1)
|
|
277
|
-
* @param {number} s saturation (a value from 0 to 1)
|
|
278
|
-
* @param {number} v value (a value from 0 to 1)
|
|
276
|
+
* @param {number} h - hue (a value from 0 to 1)
|
|
277
|
+
* @param {number} s - saturation (a value from 0 to 1)
|
|
278
|
+
* @param {number} v - value (a value from 0 to 1)
|
|
279
279
|
* @returns {Color} Reference to this object for method chaining
|
|
280
280
|
*/
|
|
281
281
|
setHSV(h, s, v) {
|
|
@@ -300,9 +300,9 @@ class Color {
|
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
302
|
* set this color to the specified HSL value
|
|
303
|
-
* @param {number} h hue (a value from 0 to 1)
|
|
304
|
-
* @param {number} s saturation (a value from 0 to 1)
|
|
305
|
-
* @param {number} l lightness (a value from 0 to 1)
|
|
303
|
+
* @param {number} h - hue (a value from 0 to 1)
|
|
304
|
+
* @param {number} s - saturation (a value from 0 to 1)
|
|
305
|
+
* @param {number} l - lightness (a value from 0 to 1)
|
|
306
306
|
* @returns {Color} Reference to this object for method chaining
|
|
307
307
|
*/
|
|
308
308
|
setHSL(h, s, l) {
|
|
@@ -375,7 +375,7 @@ class Color {
|
|
|
375
375
|
/**
|
|
376
376
|
* Linearly interpolate between this color and the given one.
|
|
377
377
|
* @param {Color} color
|
|
378
|
-
* @param {number} alpha with alpha = 0 being this color, and alpha = 1 being the given one.
|
|
378
|
+
* @param {number} alpha - with alpha = 0 being this color, and alpha = 1 being the given one.
|
|
379
379
|
* @returns {Color} Reference to this object for method chaining
|
|
380
380
|
*/
|
|
381
381
|
lerp(color, alpha) {
|
|
@@ -403,8 +403,8 @@ class Color {
|
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
405
|
* Generate random r,g,b values for this color object
|
|
406
|
-
* @param {number} [min=0] minimum value for the random range
|
|
407
|
-
* @param {number} [max=255] maxmium value for the random range
|
|
406
|
+
* @param {number} [min=0] - minimum value for the random range
|
|
407
|
+
* @param {number} [max=255] - maxmium value for the random range
|
|
408
408
|
* @returns {Color} Reference to this object for method chaining
|
|
409
409
|
*/
|
|
410
410
|
random(min = 0, max = 255) {
|
|
@@ -474,7 +474,7 @@ class Color {
|
|
|
474
474
|
* Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to
|
|
475
475
|
* the corresponding r,g,b,a values
|
|
476
476
|
* @param {string} hexColor
|
|
477
|
-
* @param {boolean} [argb = false] true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
|
|
477
|
+
* @param {boolean} [argb = false] - true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
|
|
478
478
|
* @returns {Color} Reference to this object for method chaining
|
|
479
479
|
*/
|
|
480
480
|
parseHex(hexColor, argb = false) {
|
|
@@ -530,7 +530,7 @@ class Color {
|
|
|
530
530
|
|
|
531
531
|
/**
|
|
532
532
|
* Pack this color into a Uint32 ARGB representation
|
|
533
|
-
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
533
|
+
* @param {number} [alpha=1.0] - alpha value [0.0 .. 1.0]
|
|
534
534
|
* @returns {number}
|
|
535
535
|
*/
|
|
536
536
|
toUint32(alpha = 1.0) {
|
|
@@ -590,7 +590,7 @@ class Color {
|
|
|
590
590
|
|
|
591
591
|
/**
|
|
592
592
|
* Get the color in "rgba(R,G,B,A)" format
|
|
593
|
-
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
593
|
+
* @param {number} [alpha=1.0] - alpha value [0.0 .. 1.0]
|
|
594
594
|
* @returns {string}
|
|
595
595
|
*/
|
|
596
596
|
toRGBA(alpha = this.alpha) {
|
|
@@ -606,4 +606,3 @@ class Color {
|
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
-
export default Color;
|
package/src/math/math.js
CHANGED
|
@@ -84,7 +84,7 @@ export function nextPowerOfTwo(val) {
|
|
|
84
84
|
* @public
|
|
85
85
|
* @memberof Math
|
|
86
86
|
* @name degToRad
|
|
87
|
-
* @param {number} angle angle in degrees
|
|
87
|
+
* @param {number} angle - angle in degrees
|
|
88
88
|
* @returns {number} corresponding angle in radians
|
|
89
89
|
* @example
|
|
90
90
|
* // convert a specific angle
|
|
@@ -99,7 +99,7 @@ export function degToRad(angle) {
|
|
|
99
99
|
* @public
|
|
100
100
|
* @memberof Math
|
|
101
101
|
* @name radToDeg
|
|
102
|
-
* @param {number} radians angle in radians
|
|
102
|
+
* @param {number} radians - angle in radians
|
|
103
103
|
* @returns {number} corresponding angle in degrees
|
|
104
104
|
* @example
|
|
105
105
|
* // convert a specific angle
|
|
@@ -114,9 +114,9 @@ export function radToDeg(radians) {
|
|
|
114
114
|
* @public
|
|
115
115
|
* @memberof Math
|
|
116
116
|
* @name clamp
|
|
117
|
-
* @param {number} val the value to clamp
|
|
118
|
-
* @param {number} low lower limit
|
|
119
|
-
* @param {number} high higher limit
|
|
117
|
+
* @param {number} val - the value to clamp
|
|
118
|
+
* @param {number} low - lower limit
|
|
119
|
+
* @param {number} high - higher limit
|
|
120
120
|
* @returns {number} clamped value
|
|
121
121
|
*/
|
|
122
122
|
export function clamp(val, low, high) {
|
|
@@ -128,8 +128,8 @@ export function clamp(val, low, high) {
|
|
|
128
128
|
* @public
|
|
129
129
|
* @memberof Math
|
|
130
130
|
* @name random
|
|
131
|
-
* @param {number} min minimum value.
|
|
132
|
-
* @param {number} max maximum value.
|
|
131
|
+
* @param {number} min - minimum value.
|
|
132
|
+
* @param {number} max - maximum value.
|
|
133
133
|
* @returns {number} random value
|
|
134
134
|
* @example
|
|
135
135
|
* // Print a random number; one of 5, 6, 7, 8, 9
|
|
@@ -144,8 +144,8 @@ export function random(min, max) {
|
|
|
144
144
|
* @public
|
|
145
145
|
* @memberof Math
|
|
146
146
|
* @name randomFloat
|
|
147
|
-
* @param {number} min minimum value.
|
|
148
|
-
* @param {number} max maximum value.
|
|
147
|
+
* @param {number} min - minimum value.
|
|
148
|
+
* @param {number} max - maximum value.
|
|
149
149
|
* @returns {number} random value
|
|
150
150
|
* @example
|
|
151
151
|
* // Print a random number; one of 5, 6, 7, 8, 9
|
|
@@ -160,8 +160,8 @@ export function randomFloat(min, max) {
|
|
|
160
160
|
* @public
|
|
161
161
|
* @memberof Math
|
|
162
162
|
* @name weightedRandom
|
|
163
|
-
* @param {number} min minimum value.
|
|
164
|
-
* @param {number} max maximum value.
|
|
163
|
+
* @param {number} min - minimum value.
|
|
164
|
+
* @param {number} max - maximum value.
|
|
165
165
|
* @returns {number} random value
|
|
166
166
|
* @example
|
|
167
167
|
* // Print a random number; one of 5, 6, 7, 8, 9
|
|
@@ -176,8 +176,8 @@ export function weightedRandom(min, max) {
|
|
|
176
176
|
* @public
|
|
177
177
|
* @memberof Math
|
|
178
178
|
* @name round
|
|
179
|
-
* @param {number} num value to be rounded.
|
|
180
|
-
* @param {number} [dec=0] number of decimal digit to be rounded to.
|
|
179
|
+
* @param {number} num - value to be rounded.
|
|
180
|
+
* @param {number} [dec=0] - number of decimal digit to be rounded to.
|
|
181
181
|
* @returns {number} rounded value
|
|
182
182
|
* @example
|
|
183
183
|
* // round a specific value to 2 digits
|
|
@@ -194,9 +194,9 @@ export function round(num, dec = 0) {
|
|
|
194
194
|
* @public
|
|
195
195
|
* @memberof Math
|
|
196
196
|
* @name toBeCloseTo
|
|
197
|
-
* @param {number} expected value to be compared with.
|
|
198
|
-
* @param {number} actual actual value to compare
|
|
199
|
-
* @param {number} [precision=2] float precision for the comparison
|
|
197
|
+
* @param {number} expected - value to be compared with.
|
|
198
|
+
* @param {number} actual - actual value to compare
|
|
199
|
+
* @param {number} [precision=2] - float precision for the comparison
|
|
200
200
|
* @returns {boolean} if close to
|
|
201
201
|
* @example
|
|
202
202
|
* // test if the given value is close to 10
|
package/src/math/matrix2.js
CHANGED
|
@@ -7,9 +7,9 @@ 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
|
-
class Matrix2d {
|
|
10
|
+
export default class Matrix2d {
|
|
11
11
|
/**
|
|
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.
|
|
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
|
*/
|
|
14
14
|
constructor(...args) {
|
|
15
15
|
this.onResetEvent(...args);
|
|
@@ -126,7 +126,7 @@ class Matrix2d {
|
|
|
126
126
|
* Copies over the values from another me.Matrix2d.
|
|
127
127
|
* @name copy
|
|
128
128
|
* @memberof Matrix2d
|
|
129
|
-
* @param {Matrix2d} m the matrix object to copy from
|
|
129
|
+
* @param {Matrix2d} m - the matrix object to copy from
|
|
130
130
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
131
131
|
*/
|
|
132
132
|
copy(m) {
|
|
@@ -138,7 +138,7 @@ class Matrix2d {
|
|
|
138
138
|
* Copies over the upper-left 3x3 values from the given me.Matrix3d
|
|
139
139
|
* @name fromMat3d
|
|
140
140
|
* @memberof Matrix2d
|
|
141
|
-
* @param {Matrix3d} m the matrix object to copy from
|
|
141
|
+
* @param {Matrix3d} m - the matrix object to copy from
|
|
142
142
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
143
143
|
*/
|
|
144
144
|
fromMat3d(m) {
|
|
@@ -162,7 +162,7 @@ class Matrix2d {
|
|
|
162
162
|
* multiply both matrix
|
|
163
163
|
* @name multiply
|
|
164
164
|
* @memberof Matrix2d
|
|
165
|
-
* @param {Matrix2d} m the other matrix
|
|
165
|
+
* @param {Matrix2d} m - the other matrix
|
|
166
166
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
167
167
|
*/
|
|
168
168
|
multiply(m) {
|
|
@@ -249,7 +249,7 @@ class Matrix2d {
|
|
|
249
249
|
* apply the current transform to the given 2d or 3d vector
|
|
250
250
|
* @name apply
|
|
251
251
|
* @memberof Matrix2d
|
|
252
|
-
* @param {Vector2d|Vector3d} v the vector object to be transformed
|
|
252
|
+
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
253
253
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
254
254
|
*/
|
|
255
255
|
apply(v) {
|
|
@@ -272,7 +272,7 @@ class Matrix2d {
|
|
|
272
272
|
* apply the inverted current transform to the given 2d vector
|
|
273
273
|
* @name applyInverse
|
|
274
274
|
* @memberof Matrix2d
|
|
275
|
-
* @param {Vector2d} v the vector object to be transformed
|
|
275
|
+
* @param {Vector2d} v - the vector object to be transformed
|
|
276
276
|
* @returns {Vector2d} result vector object.
|
|
277
277
|
*/
|
|
278
278
|
applyInverse(v) {
|
|
@@ -292,8 +292,8 @@ class Matrix2d {
|
|
|
292
292
|
* scale the matrix
|
|
293
293
|
* @name scale
|
|
294
294
|
* @memberof Matrix2d
|
|
295
|
-
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
296
|
-
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
295
|
+
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
296
|
+
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
297
297
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
298
298
|
*/
|
|
299
299
|
scale(x, y) {
|
|
@@ -313,7 +313,7 @@ class Matrix2d {
|
|
|
313
313
|
* adds a 2D scaling transformation.
|
|
314
314
|
* @name scaleV
|
|
315
315
|
* @memberof Matrix2d
|
|
316
|
-
* @param {Vector2d} v scaling vector
|
|
316
|
+
* @param {Vector2d} v - scaling vector
|
|
317
317
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
318
318
|
*/
|
|
319
319
|
scaleV(v) {
|
|
@@ -324,7 +324,7 @@ class Matrix2d {
|
|
|
324
324
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
325
325
|
* @name scaleX
|
|
326
326
|
* @memberof Matrix2d
|
|
327
|
-
* @param {number} x x scaling vector
|
|
327
|
+
* @param {number} x - x scaling vector
|
|
328
328
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
329
329
|
*/
|
|
330
330
|
scaleX(x) {
|
|
@@ -335,7 +335,7 @@ class Matrix2d {
|
|
|
335
335
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
336
336
|
* @name scaleY
|
|
337
337
|
* @memberof Matrix2d
|
|
338
|
-
* @param {number} y y scaling vector
|
|
338
|
+
* @param {number} y - y scaling vector
|
|
339
339
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
340
340
|
*/
|
|
341
341
|
scaleY(y) {
|
|
@@ -346,7 +346,7 @@ class Matrix2d {
|
|
|
346
346
|
* rotate the matrix (counter-clockwise) by the specified angle (in radians).
|
|
347
347
|
* @name rotate
|
|
348
348
|
* @memberof Matrix2d
|
|
349
|
-
* @param {number} angle Rotation angle in radians.
|
|
349
|
+
* @param {number} angle - Rotation angle in radians.
|
|
350
350
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
351
351
|
*/
|
|
352
352
|
rotate(angle) {
|
|
@@ -377,15 +377,15 @@ class Matrix2d {
|
|
|
377
377
|
* @name translate
|
|
378
378
|
* @memberof Matrix2d
|
|
379
379
|
* @method
|
|
380
|
-
* @param {number} x the x coordindates to translate the matrix by
|
|
381
|
-
* @param {number} y the y coordindates to translate the matrix by
|
|
380
|
+
* @param {number} x - the x coordindates to translate the matrix by
|
|
381
|
+
* @param {number} y - the y coordindates to translate the matrix by
|
|
382
382
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
383
383
|
*/
|
|
384
384
|
/**
|
|
385
385
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
386
386
|
* @name translateV
|
|
387
387
|
* @memberof Matrix2d
|
|
388
|
-
* @param {Vector2d} v the vector to translate the matrix by
|
|
388
|
+
* @param {Vector2d} v - the vector to translate the matrix by
|
|
389
389
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
390
390
|
*/
|
|
391
391
|
translate() {
|
|
@@ -434,7 +434,7 @@ class Matrix2d {
|
|
|
434
434
|
* return true if the two matrices are identical
|
|
435
435
|
* @name equals
|
|
436
436
|
* @memberof Matrix2d
|
|
437
|
-
* @param {Matrix2d} m the other matrix
|
|
437
|
+
* @param {Matrix2d} m - the other matrix
|
|
438
438
|
* @returns {boolean} true if both are equals
|
|
439
439
|
*/
|
|
440
440
|
equals(m) {
|
|
@@ -491,4 +491,3 @@ class Matrix2d {
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
-
export default Matrix2d;
|
package/src/math/matrix3.js
CHANGED
|
@@ -5,9 +5,9 @@ import { EPSILON } from "./math.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a 4x4 Matrix3d Object
|
|
7
7
|
*/
|
|
8
|
-
class Matrix3d {
|
|
8
|
+
export default class Matrix3d {
|
|
9
9
|
/**
|
|
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.
|
|
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
|
*/
|
|
12
12
|
constructor(...args) {
|
|
13
13
|
this.onResetEvent(...args);
|
|
@@ -131,7 +131,7 @@ class Matrix3d {
|
|
|
131
131
|
* Copies over the values from another me.Matrix3d.
|
|
132
132
|
* @name copy
|
|
133
133
|
* @memberof Matrix3d
|
|
134
|
-
* @param {Matrix3d} m the matrix object to copy from
|
|
134
|
+
* @param {Matrix3d} m - the matrix object to copy from
|
|
135
135
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
136
136
|
*/
|
|
137
137
|
copy(m) {
|
|
@@ -143,7 +143,7 @@ class Matrix3d {
|
|
|
143
143
|
* Copies over the upper-left 2x2 values from the given me.Matrix2d
|
|
144
144
|
* @name fromMat2d
|
|
145
145
|
* @memberof Matrix3d
|
|
146
|
-
* @param {Matrix2d} m the matrix object to copy from
|
|
146
|
+
* @param {Matrix2d} m - the matrix object to copy from
|
|
147
147
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
148
148
|
*/
|
|
149
149
|
fromMat2d(m) {
|
|
@@ -161,7 +161,7 @@ class Matrix3d {
|
|
|
161
161
|
* multiply both matrix
|
|
162
162
|
* @name multiply
|
|
163
163
|
* @memberof Matrix3d
|
|
164
|
-
* @param {Matrix3d} m Other matrix
|
|
164
|
+
* @param {Matrix3d} m - Other matrix
|
|
165
165
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
166
166
|
*/
|
|
167
167
|
multiply(m) {
|
|
@@ -306,7 +306,7 @@ class Matrix3d {
|
|
|
306
306
|
* apply the current transform to the given 2d or 3d vector
|
|
307
307
|
* @name apply
|
|
308
308
|
* @memberof Matrix3d
|
|
309
|
-
* @param {Vector2d|Vector3d} v the vector object to be transformed
|
|
309
|
+
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
310
310
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
311
311
|
*/
|
|
312
312
|
apply(v) {
|
|
@@ -331,7 +331,7 @@ class Matrix3d {
|
|
|
331
331
|
* apply the inverted current transform to the given 2d or 3d vector
|
|
332
332
|
* @name applyInverse
|
|
333
333
|
* @memberof Matrix3d
|
|
334
|
-
* @param {Vector2d|Vector3d} v the vector object to be transformed
|
|
334
|
+
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
335
335
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
336
336
|
*/
|
|
337
337
|
applyInverse(v) {
|
|
@@ -351,12 +351,12 @@ class Matrix3d {
|
|
|
351
351
|
* <img src="images/glOrtho.gif"/><br>
|
|
352
352
|
* @name ortho
|
|
353
353
|
* @memberof Matrix3d
|
|
354
|
-
* @param {number} left farthest left on the x-axis
|
|
355
|
-
* @param {number} right farthest right on the x-axis
|
|
356
|
-
* @param {number} bottom farthest down on the y-axis
|
|
357
|
-
* @param {number} top farthest up on the y-axis
|
|
358
|
-
* @param {number} near distance to the near clipping plane along the -Z axis
|
|
359
|
-
* @param {number} far distance to the far clipping plane along the -Z axis
|
|
354
|
+
* @param {number} left - farthest left on the x-axis
|
|
355
|
+
* @param {number} right - farthest right on the x-axis
|
|
356
|
+
* @param {number} bottom - farthest down on the y-axis
|
|
357
|
+
* @param {number} top - farthest up on the y-axis
|
|
358
|
+
* @param {number} near - distance to the near clipping plane along the -Z axis
|
|
359
|
+
* @param {number} far - distance to the far clipping plane along the -Z axis
|
|
360
360
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
361
361
|
*/
|
|
362
362
|
ortho(left, right, bottom, top, near, far) {
|
|
@@ -389,9 +389,9 @@ class Matrix3d {
|
|
|
389
389
|
* scale the matrix
|
|
390
390
|
* @name scale
|
|
391
391
|
* @memberof Matrix3d
|
|
392
|
-
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
393
|
-
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
394
|
-
* @param {number} [z=0] a number representing the depth vector
|
|
392
|
+
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
393
|
+
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
394
|
+
* @param {number} [z=0] - a number representing the depth vector
|
|
395
395
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
396
396
|
*/
|
|
397
397
|
scale(x, y, z) {
|
|
@@ -422,7 +422,7 @@ class Matrix3d {
|
|
|
422
422
|
* adds a 2D scaling transformation.
|
|
423
423
|
* @name scaleV
|
|
424
424
|
* @memberof Matrix3d
|
|
425
|
-
* @param {Vector2d|Vector3d} v scaling vector
|
|
425
|
+
* @param {Vector2d|Vector3d} v - scaling vector
|
|
426
426
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
427
427
|
*/
|
|
428
428
|
scaleV(v) {
|
|
@@ -433,7 +433,7 @@ class Matrix3d {
|
|
|
433
433
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
434
434
|
* @name scaleX
|
|
435
435
|
* @memberof Matrix3d
|
|
436
|
-
* @param {number} x x scaling vector
|
|
436
|
+
* @param {number} x - x scaling vector
|
|
437
437
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
438
438
|
*/
|
|
439
439
|
scaleX(x) {
|
|
@@ -444,7 +444,7 @@ class Matrix3d {
|
|
|
444
444
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
445
445
|
* @name scaleY
|
|
446
446
|
* @memberof Matrix3d
|
|
447
|
-
* @param {number} y y scaling vector
|
|
447
|
+
* @param {number} y - y scaling vector
|
|
448
448
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
449
449
|
*/
|
|
450
450
|
scaleY(y) {
|
|
@@ -455,8 +455,8 @@ class Matrix3d {
|
|
|
455
455
|
* rotate this matrix (counter-clockwise) by the specified angle (in radians).
|
|
456
456
|
* @name rotate
|
|
457
457
|
* @memberof Matrix3d
|
|
458
|
-
* @param {number} angle Rotation angle in radians.
|
|
459
|
-
* @param {Vector3d} v the axis to rotate around
|
|
458
|
+
* @param {number} angle - Rotation angle in radians.
|
|
459
|
+
* @param {Vector3d} v - the axis to rotate around
|
|
460
460
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
461
461
|
*/
|
|
462
462
|
rotate(angle, v) {
|
|
@@ -535,16 +535,16 @@ class Matrix3d {
|
|
|
535
535
|
* @name translate
|
|
536
536
|
* @memberof Matrix3d
|
|
537
537
|
* @method
|
|
538
|
-
* @param {number} x a number representing the abscissa of the vector.
|
|
539
|
-
* @param {number} [y=x] a number representing the ordinate of the vector.
|
|
540
|
-
* @param {number} [z=0] a number representing the depth of the vector
|
|
538
|
+
* @param {number} x - a number representing the abscissa of the vector.
|
|
539
|
+
* @param {number} [y=x] - a number representing the ordinate of the vector.
|
|
540
|
+
* @param {number} [z=0] - a number representing the depth of the vector
|
|
541
541
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
542
542
|
*/
|
|
543
543
|
/**
|
|
544
544
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
545
545
|
* @name translateV
|
|
546
546
|
* @memberof Matrix3d
|
|
547
|
-
* @param {Vector2d|Vector3d} v the vector to translate the matrix by
|
|
547
|
+
* @param {Vector2d|Vector3d} v - the vector to translate the matrix by
|
|
548
548
|
* @returns {Matrix3d} Reference to this object for method chaining
|
|
549
549
|
*/
|
|
550
550
|
translate() {
|
|
@@ -604,7 +604,7 @@ class Matrix3d {
|
|
|
604
604
|
* return true if the two matrices are identical
|
|
605
605
|
* @name equals
|
|
606
606
|
* @memberof Matrix3d
|
|
607
|
-
* @param {Matrix3d} m the other matrix
|
|
607
|
+
* @param {Matrix3d} m - the other matrix
|
|
608
608
|
* @returns {boolean} true if both are equals
|
|
609
609
|
*/
|
|
610
610
|
equals(m) {
|
|
@@ -669,4 +669,3 @@ class Matrix3d {
|
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
-
export default Matrix3d;
|
|
@@ -7,13 +7,13 @@ import {clamp} from "./math.js";
|
|
|
7
7
|
* A Vector2d object that provide notification by executing the given callback when the vector is changed.
|
|
8
8
|
* @augments Vector2d
|
|
9
9
|
*/
|
|
10
|
-
class ObservableVector2d extends Vector2d {
|
|
10
|
+
export default class ObservableVector2d extends Vector2d {
|
|
11
11
|
/**
|
|
12
|
-
* @param {number} x x value of the vector
|
|
13
|
-
* @param {number} y y value of the vector
|
|
14
|
-
* @param {object} settings additional required parameters
|
|
15
|
-
* @param {Function} settings.onUpdate the callback to be executed when the vector is changed
|
|
16
|
-
* @param {Function} [settings.scope] the value to use as this when calling onUpdate
|
|
12
|
+
* @param {number} x - x value of the vector
|
|
13
|
+
* @param {number} y - y value of the vector
|
|
14
|
+
* @param {object} settings - additional required parameters
|
|
15
|
+
* @param {Function} settings.onUpdate - the callback to be executed when the vector is changed
|
|
16
|
+
* @param {Function} [settings.scope] - the value to use as this when calling onUpdate
|
|
17
17
|
*/
|
|
18
18
|
constructor(x = 0, y = 0, settings) {
|
|
19
19
|
super(x, y);
|
|
@@ -97,8 +97,8 @@ class ObservableVector2d extends Vector2d {
|
|
|
97
97
|
* set the vector value without triggering the callback
|
|
98
98
|
* @name setMuted
|
|
99
99
|
* @memberof ObservableVector2d
|
|
100
|
-
* @param {number} x x value of the vector
|
|
101
|
-
* @param {number} y y value of the vector
|
|
100
|
+
* @param {number} x - x value of the vector
|
|
101
|
+
* @param {number} y - y value of the vector
|
|
102
102
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
103
103
|
*/
|
|
104
104
|
setMuted(x, y) {
|
|
@@ -111,8 +111,8 @@ class ObservableVector2d extends Vector2d {
|
|
|
111
111
|
* set the callback to be executed when the vector is changed
|
|
112
112
|
* @name setCallback
|
|
113
113
|
* @memberof ObservableVector2d
|
|
114
|
-
* @param {Function} fn callback
|
|
115
|
-
* @param {Function} [scope=null] scope
|
|
114
|
+
* @param {Function} fn - callback
|
|
115
|
+
* @param {Function} [scope=null] - scope
|
|
116
116
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
117
117
|
*/
|
|
118
118
|
setCallback(fn, scope = null) {
|
|
@@ -175,7 +175,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
175
175
|
* Divide this vector values by the passed value
|
|
176
176
|
* @name div
|
|
177
177
|
* @memberof ObservableVector2d
|
|
178
|
-
* @param {number} n the value to divide the vector by
|
|
178
|
+
* @param {number} n - the value to divide the vector by
|
|
179
179
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
180
180
|
*/
|
|
181
181
|
div(n) {
|
|
@@ -335,8 +335,8 @@ class ObservableVector2d extends Vector2d {
|
|
|
335
335
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
336
336
|
* @name rotate
|
|
337
337
|
* @memberof ObservableVector2d
|
|
338
|
-
* @param {number} angle The angle to rotate (in radians)
|
|
339
|
-
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
|
|
338
|
+
* @param {number} angle - The angle to rotate (in radians)
|
|
339
|
+
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around
|
|
340
340
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
341
341
|
*/
|
|
342
342
|
rotate(angle, v) {
|
|
@@ -384,7 +384,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
384
384
|
* @name lerp
|
|
385
385
|
* @memberof ObservableVector2d
|
|
386
386
|
* @param {Vector2d|ObservableVector2d} v
|
|
387
|
-
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
387
|
+
* @param {number} alpha - distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
388
388
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
389
389
|
*/
|
|
390
390
|
lerp(v, alpha) {
|
|
@@ -399,7 +399,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
399
399
|
* @name moveTowards
|
|
400
400
|
* @memberof ObservableVector2d
|
|
401
401
|
* @param {Vector2d|ObservableVector2d} target
|
|
402
|
-
* @param {number} step the maximum step per iteration (Negative values will push the vector away from the target)
|
|
402
|
+
* @param {number} step - the maximum step per iteration (Negative values will push the vector away from the target)
|
|
403
403
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
404
404
|
*/
|
|
405
405
|
moveTowards(target, step) {
|
|
@@ -459,4 +459,3 @@ class ObservableVector2d extends Vector2d {
|
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
-
export default ObservableVector2d;
|
|
@@ -7,14 +7,14 @@ import pool from "./../system/pooling.js";
|
|
|
7
7
|
* A Vector3d object that provide notification by executing the given callback when the vector is changed.
|
|
8
8
|
* @augments Vector3d
|
|
9
9
|
*/
|
|
10
|
-
class ObservableVector3d extends Vector3d {
|
|
10
|
+
export default class ObservableVector3d extends Vector3d {
|
|
11
11
|
/**
|
|
12
|
-
* @param {number} x x value of the vector
|
|
13
|
-
* @param {number} y y value of the vector
|
|
14
|
-
* @param {number} z z value of the vector
|
|
15
|
-
* @param {object} settings additional required parameters
|
|
16
|
-
* @param {Function} settings.onUpdate the callback to be executed when the vector is changed
|
|
17
|
-
* @param {object} [settings.scope] the value to use as this when calling onUpdate
|
|
12
|
+
* @param {number} x - x value of the vector
|
|
13
|
+
* @param {number} y - y value of the vector
|
|
14
|
+
* @param {number} z - z value of the vector
|
|
15
|
+
* @param {object} settings - additional required parameters
|
|
16
|
+
* @param {Function} settings.onUpdate - the callback to be executed when the vector is changed
|
|
17
|
+
* @param {object} [settings.scope] - the value to use as this when calling onUpdate
|
|
18
18
|
*/
|
|
19
19
|
constructor(x = 0, y = 0, z = 0, settings) {
|
|
20
20
|
super(x, y, z);
|
|
@@ -124,9 +124,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
124
124
|
* set the vector value without triggering the callback
|
|
125
125
|
* @name setMuted
|
|
126
126
|
* @memberof ObservableVector3d
|
|
127
|
-
* @param {number} x x value of the vector
|
|
128
|
-
* @param {number} y y value of the vector
|
|
129
|
-
* @param {number} [z=0] z value of the vector
|
|
127
|
+
* @param {number} x - x value of the vector
|
|
128
|
+
* @param {number} y - y value of the vector
|
|
129
|
+
* @param {number} [z=0] - z value of the vector
|
|
130
130
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
131
131
|
*/
|
|
132
132
|
setMuted(x, y, z) {
|
|
@@ -140,8 +140,8 @@ class ObservableVector3d extends Vector3d {
|
|
|
140
140
|
* set the callback to be executed when the vector is changed
|
|
141
141
|
* @name setCallback
|
|
142
142
|
* @memberof ObservableVector3d
|
|
143
|
-
* @param {Function} fn callback
|
|
144
|
-
* @param {Function} [scope=null] scope
|
|
143
|
+
* @param {Function} fn - callback
|
|
144
|
+
* @param {Function} [scope=null] - scope
|
|
145
145
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
146
146
|
*/
|
|
147
147
|
setCallback(fn, scope = null) {
|
|
@@ -206,7 +206,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
206
206
|
* Divide this vector values by the passed value
|
|
207
207
|
* @name div
|
|
208
208
|
* @memberof ObservableVector3d
|
|
209
|
-
* @param {number} n the value to divide the vector by
|
|
209
|
+
* @param {number} n - the value to divide the vector by
|
|
210
210
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
211
211
|
*/
|
|
212
212
|
div(n) {
|
|
@@ -404,8 +404,8 @@ class ObservableVector3d extends Vector3d {
|
|
|
404
404
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
405
405
|
* @name rotate
|
|
406
406
|
* @memberof ObservableVector3d
|
|
407
|
-
* @param {number} angle The angle to rotate (in radians)
|
|
408
|
-
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around (on the same z axis)
|
|
407
|
+
* @param {number} angle - The angle to rotate (in radians)
|
|
408
|
+
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around (on the same z axis)
|
|
409
409
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
410
410
|
*/
|
|
411
411
|
rotate(angle, v) {
|
|
@@ -461,7 +461,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
461
461
|
* @name lerp
|
|
462
462
|
* @memberof ObservableVector3d
|
|
463
463
|
* @param {Vector3d|ObservableVector3d} v
|
|
464
|
-
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
464
|
+
* @param {number} alpha - distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
465
465
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
466
466
|
*/
|
|
467
467
|
lerp(v, alpha) {
|
|
@@ -477,7 +477,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
477
477
|
* @name moveTowards
|
|
478
478
|
* @memberof ObservableVector3d
|
|
479
479
|
* @param {Vector2d|ObservableVector2d|Vector3d|ObservableVector3d} target
|
|
480
|
-
* @param {number} step the maximum step per iteration (Negative values will push the vector away from the target)
|
|
480
|
+
* @param {number} step - the maximum step per iteration (Negative values will push the vector away from the target)
|
|
481
481
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
482
482
|
*/
|
|
483
483
|
moveTowards(target, step) {
|
|
@@ -549,4 +549,3 @@ class ObservableVector3d extends Vector3d {
|
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
|
|
552
|
-
export default ObservableVector3d;
|