melonjs 14.5.0 → 15.1.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/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.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 +7 -3
- package/dist/melonjs.mjs/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +27 -17
- package/dist/melonjs.mjs/application/header.js +6 -5
- package/dist/melonjs.mjs/application/resize.js +20 -20
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +18 -20
- package/dist/melonjs.mjs/camera/camera2d.js +10 -10
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +4 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
- package/dist/melonjs.mjs/geometries/line.js +9 -9
- package/dist/melonjs.mjs/geometries/path2d.js +56 -56
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +29 -29
- package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
- package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
- package/dist/melonjs.mjs/index.js +8 -6
- package/dist/melonjs.mjs/input/gamepad.js +30 -30
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +15 -15
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +59 -59
- package/dist/melonjs.mjs/lang/console.js +3 -3
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +9 -9
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
- 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 +7 -7
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +13 -13
- package/dist/melonjs.mjs/loader/settings.js +3 -3
- package/dist/melonjs.mjs/math/color.js +25 -24
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +22 -22
- package/dist/melonjs.mjs/math/matrix3.js +52 -52
- package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
- package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
- package/dist/melonjs.mjs/math/vector2.js +11 -11
- package/dist/melonjs.mjs/math/vector3.js +21 -21
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- 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 +5 -5
- package/dist/melonjs.mjs/particles/particle.js +8 -8
- package/dist/melonjs.mjs/particles/settings.js +3 -3
- package/dist/melonjs.mjs/physics/body.js +17 -17
- package/dist/melonjs.mjs/physics/bounds.js +12 -12
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +14 -14
- package/dist/melonjs.mjs/physics/quadtree.js +19 -19
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +60 -60
- package/dist/melonjs.mjs/physics/world.js +4 -4
- package/dist/melonjs.mjs/plugin/plugin.js +11 -11
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +77 -59
- package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
- package/dist/melonjs.mjs/renderable/light2d.js +6 -6
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
- package/dist/melonjs.mjs/renderable/renderable.js +35 -13
- package/dist/melonjs.mjs/renderable/sprite.js +25 -25
- package/dist/melonjs.mjs/renderable/trigger.js +11 -9
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -65
- package/dist/melonjs.mjs/state/stage.js +7 -7
- package/dist/melonjs.mjs/state/state.js +15 -15
- package/dist/melonjs.mjs/system/device.js +3 -3
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +9 -9
- package/dist/melonjs.mjs/system/save.js +6 -6
- package/dist/melonjs.mjs/system/timer.js +16 -12
- package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
- package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
- package/dist/melonjs.mjs/text/glyph.js +3 -3
- package/dist/melonjs.mjs/text/text.js +63 -92
- package/dist/melonjs.mjs/text/textmetrics.js +15 -15
- package/dist/melonjs.mjs/text/textstyle.js +4 -6
- package/dist/melonjs.mjs/tweens/easing.js +4 -4
- package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
- package/dist/melonjs.mjs/tweens/tween.js +11 -11
- package/dist/melonjs.mjs/utils/agent.js +6 -6
- package/dist/melonjs.mjs/utils/array.js +4 -4
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +5 -5
- package/dist/melonjs.mjs/utils/string.js +3 -3
- package/dist/melonjs.mjs/utils/utils.js +16 -16
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +41 -119
- package/dist/melonjs.mjs/video/renderer.js +70 -14
- package/dist/melonjs.mjs/video/texture/atlas.js +39 -45
- package/dist/melonjs.mjs/video/texture/cache.js +9 -10
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +2 -2
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +23 -19
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +80 -80
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +77 -0
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +252 -0
- package/dist/melonjs.mjs/video/webgl/compositors/webgl_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +188 -181
- package/dist/melonjs.module.js +25040 -25193
- package/dist/types/application/application.d.ts +11 -8
- package/dist/types/audio/audio.d.ts +3 -3
- package/dist/types/entity/entity.d.ts +1 -1
- package/dist/types/index.d.ts +7 -4
- package/dist/types/input/input.d.ts +1 -1
- package/dist/types/input/keyboard.d.ts +1 -1
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/level.d.ts +2 -2
- package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
- package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
- package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
- package/dist/types/loader/loader.d.ts +2 -2
- package/dist/types/loader/settings.d.ts +2 -2
- package/dist/types/particles/emitter.d.ts +1 -1
- package/dist/types/physics/collision.d.ts +1 -1
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/plugin/plugin.d.ts +2 -2
- package/dist/types/renderable/container.d.ts +21 -17
- package/dist/types/renderable/renderable.d.ts +6 -0
- package/dist/types/renderable/sprite.d.ts +11 -11
- package/dist/types/renderable/trigger.d.ts +1 -1
- package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
- package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
- package/dist/types/renderable/ui/uitextbutton.d.ts +52 -12
- package/dist/types/state/stage.d.ts +1 -1
- package/dist/types/system/device.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +3 -3
- package/dist/types/system/timer.d.ts +5 -5
- package/dist/types/text/bitmaptext.d.ts +1 -1
- package/dist/types/text/text.d.ts +7 -21
- package/dist/types/text/textstyle.d.ts +1 -1
- package/dist/types/utils/array.d.ts +2 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +8 -81
- package/dist/types/video/renderer.d.ts +48 -4
- package/dist/types/video/texture/atlas.d.ts +3 -3
- package/dist/types/video/texture/canvas_texture.d.ts +40 -0
- package/dist/types/video/webgl/buffer/vertex.d.ts +3 -3
- package/dist/types/video/webgl/compositors/compositor.d.ts +38 -32
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +22 -0
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +72 -0
- package/dist/types/video/webgl/glshader.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +47 -37
- package/package.json +16 -17
- package/src/application/application.js +26 -16
- package/src/application/header.js +5 -4
- package/src/application/resize.js +19 -19
- package/src/audio/audio.js +17 -19
- package/src/camera/camera2d.js +9 -9
- package/src/entity/entity.js +3 -3
- package/src/geometries/ellipse.js +5 -5
- package/src/geometries/line.js +8 -8
- package/src/geometries/path2d.js +55 -55
- package/src/geometries/point.js +1 -1
- package/src/geometries/poly.js +28 -28
- package/src/geometries/rectangle.js +7 -7
- package/src/geometries/roundrect.js +5 -5
- package/src/index.js +9 -4
- package/src/input/gamepad.js +29 -29
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -14
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +52 -52
- package/src/lang/console.js +2 -2
- package/src/lang/deprecated.js +1 -1
- package/src/level/level.js +8 -8
- package/src/level/tiled/TMXGroup.js +2 -2
- package/src/level/tiled/TMXLayer.js +30 -30
- package/src/level/tiled/TMXObject.js +7 -7
- package/src/level/tiled/TMXTile.js +7 -7
- package/src/level/tiled/TMXTileMap.js +18 -18
- package/src/level/tiled/TMXTileset.js +14 -14
- package/src/level/tiled/TMXTilesetGroup.js +2 -2
- package/src/level/tiled/TMXUtils.js +45 -40
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
- package/src/loader/loader.js +6 -6
- package/src/loader/loadingscreen.js +1 -1
- package/src/loader/parser.js +12 -12
- package/src/loader/settings.js +2 -2
- package/src/math/color.js +24 -23
- package/src/math/math.js +1 -1
- package/src/math/matrix2.js +21 -21
- package/src/math/matrix3.js +51 -51
- package/src/math/observable_vector2.js +11 -11
- package/src/math/observable_vector3.js +21 -21
- package/src/math/vector2.js +10 -10
- package/src/math/vector3.js +20 -20
- package/src/particles/emitter.js +4 -4
- package/src/particles/particle.js +7 -7
- package/src/particles/settings.js +2 -2
- package/src/physics/body.js +16 -16
- package/src/physics/bounds.js +11 -11
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +18 -18
- package/src/physics/sat.js +59 -59
- package/src/physics/world.js +3 -3
- package/src/plugin/plugin.js +8 -8
- package/src/polyfill/index.js +0 -2
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/container.js +76 -58
- package/src/renderable/dragndrop.js +4 -4
- package/src/renderable/imagelayer.js +6 -5
- package/src/renderable/light2d.js +5 -5
- package/src/renderable/nineslicesprite.js +11 -11
- package/src/renderable/renderable.js +34 -12
- package/src/renderable/sprite.js +24 -24
- package/src/renderable/trigger.js +10 -8
- package/src/renderable/ui/uibaseelement.js +96 -26
- package/src/renderable/ui/uispriteelement.js +24 -24
- package/src/renderable/ui/uitextbutton.js +85 -67
- package/src/state/stage.js +6 -6
- package/src/state/state.js +14 -14
- package/src/system/device.js +2 -2
- package/src/system/event.js +1 -1
- package/src/system/pooling.js +8 -8
- package/src/system/save.js +5 -5
- package/src/system/timer.js +15 -11
- package/src/text/bitmaptext.js +19 -19
- package/src/text/bitmaptextdata.js +21 -21
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +62 -91
- package/src/text/textmetrics.js +14 -14
- package/src/text/textstyle.js +3 -5
- package/src/tweens/easing.js +3 -3
- package/src/tweens/interpolation.js +7 -7
- package/src/tweens/tween.js +10 -10
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +3 -3
- package/src/utils/function.js +4 -4
- package/src/utils/string.js +2 -2
- package/src/utils/utils.js +15 -15
- package/src/video/canvas/canvas_renderer.js +39 -117
- package/src/video/renderer.js +68 -12
- package/src/video/texture/atlas.js +38 -44
- package/src/video/texture/cache.js +6 -6
- package/src/video/texture/canvas_texture.js +62 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +22 -18
- package/src/video/webgl/compositors/compositor.js +79 -80
- package/src/video/webgl/compositors/primitive_compositor.js +68 -0
- package/src/video/webgl/compositors/{webgl_compositor.js → quad_compositor.js} +52 -109
- package/src/video/webgl/glshader.js +6 -6
- package/src/video/webgl/shaders/primitive.vert +2 -5
- package/src/video/webgl/shaders/quad.vert +3 -1
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/program.js +6 -6
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_renderer.js +186 -179
- package/dist/melonjs.mjs/_virtual/make-built-in.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-define-property.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +0 -10
- package/dist/melonjs.mjs/_virtual/shared.js +0 -10
- package/dist/melonjs.mjs/game.js +0 -29
- package/dist/melonjs.mjs/polyfill/console.js +0 -18
- package/dist/melonjs.mjs/polyfill/performance.js +0 -27
- package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +0 -46
- package/dist/melonjs.mjs/polyfill/roundrect.js +0 -242
- package/dist/melonjs.mjs/renderable/re_container.js +0 -1016
- package/dist/melonjs.mjs/video/utils/resize.js +0 -116
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +0 -494
- package/src/polyfill/performance.js +0 -20
- package/src/polyfill/requestAnimationFrame.js +0 -39
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -91,14 +91,14 @@ import pool from '../system/pooling.js';
|
|
|
91
91
|
* @returns {Ellipse} this instance for objecf chaining
|
|
92
92
|
*/
|
|
93
93
|
setShape(x, y, w, h) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const hW = w / 2;
|
|
95
|
+
const hH = h / 2;
|
|
96
96
|
|
|
97
97
|
this.pos.set(x, y);
|
|
98
98
|
this.radius = Math.max(hW, hH);
|
|
99
99
|
this.ratio.set(hW / this.radius, hH / this.radius);
|
|
100
100
|
this.radiusV.set(this.radius, this.radius).scaleV(this.ratio);
|
|
101
|
-
|
|
101
|
+
const r = this.radius * this.radius;
|
|
102
102
|
this.radiusSq.set(r, r).scaleV(this.ratio);
|
|
103
103
|
|
|
104
104
|
// update the corresponding bounds
|
|
@@ -182,7 +182,7 @@ import pool from '../system/pooling.js';
|
|
|
182
182
|
* @returns {Ellipse} this ellipse
|
|
183
183
|
*/
|
|
184
184
|
translate() {
|
|
185
|
-
|
|
185
|
+
let _x, _y;
|
|
186
186
|
|
|
187
187
|
if (arguments.length === 2) {
|
|
188
188
|
// x, y
|
|
@@ -219,7 +219,7 @@ import pool from '../system/pooling.js';
|
|
|
219
219
|
* @returns {boolean} true if contains
|
|
220
220
|
*/
|
|
221
221
|
contains() {
|
|
222
|
-
|
|
222
|
+
let _x, _y;
|
|
223
223
|
|
|
224
224
|
if (arguments.length === 2) {
|
|
225
225
|
// x, y
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -37,7 +37,7 @@ import Polygon from './poly.js';
|
|
|
37
37
|
* @returns {boolean} true if contains
|
|
38
38
|
*/
|
|
39
39
|
contains() {
|
|
40
|
-
|
|
40
|
+
let _x, _y;
|
|
41
41
|
|
|
42
42
|
if (arguments.length === 2) {
|
|
43
43
|
// x, y
|
|
@@ -53,8 +53,8 @@ import Polygon from './poly.js';
|
|
|
53
53
|
// rather than creating temp translated vectors
|
|
54
54
|
_x -= this.pos.x; // Cx
|
|
55
55
|
_y -= this.pos.y; // Cy
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
let start = this.points[0]; // Ax/Ay
|
|
57
|
+
let end = this.points[1]; // Bx/By
|
|
58
58
|
|
|
59
59
|
//(Cy - Ay) * (Bx - Ax) = (By - Ay) * (Cx - Ax)
|
|
60
60
|
return (_y - start.y) * (end.x - start.x) === (end.y - start.y) * (_x - start.x);
|
|
@@ -68,12 +68,12 @@ import Polygon from './poly.js';
|
|
|
68
68
|
* @returns {Line} this instance for objecf chaining
|
|
69
69
|
*/
|
|
70
70
|
recalc() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
let edges = this.edges;
|
|
72
|
+
let normals = this.normals;
|
|
73
|
+
let indices = this.indices;
|
|
74
74
|
|
|
75
75
|
// Copy the original points array and apply the offset/angle
|
|
76
|
-
|
|
76
|
+
let points = this.points;
|
|
77
77
|
|
|
78
78
|
if (points.length !== 2) {
|
|
79
79
|
throw new Error("Requires exactly 2 points");
|
|
@@ -103,7 +103,7 @@ import Polygon from './poly.js';
|
|
|
103
103
|
* @returns {Line} new Line
|
|
104
104
|
*/
|
|
105
105
|
clone() {
|
|
106
|
-
|
|
106
|
+
let copy = [];
|
|
107
107
|
this.points.forEach((point) => {
|
|
108
108
|
copy.push(point.clone());
|
|
109
109
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -50,7 +50,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
50
50
|
* If the shape has already been closed or has only one point, this function does nothing.
|
|
51
51
|
*/
|
|
52
52
|
closePath() {
|
|
53
|
-
|
|
53
|
+
let points = this.points;
|
|
54
54
|
if (points.length > 1 && !points[points.length-1].equals(points[0])) {
|
|
55
55
|
points.push(pool.pull("Point", points[0].x, points[0].y));
|
|
56
56
|
}
|
|
@@ -61,10 +61,10 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
61
61
|
* @returns {Point[]}
|
|
62
62
|
*/
|
|
63
63
|
triangulatePath() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
let i = 0;
|
|
65
|
+
let points = this.points;
|
|
66
|
+
let vertices = this.vertices;
|
|
67
|
+
let indices = earcutExports(points.flatMap(p => [p.x, p.y]));
|
|
68
68
|
|
|
69
69
|
// pre-allocate vertices if necessary
|
|
70
70
|
while (vertices.length < indices.length) {
|
|
@@ -73,7 +73,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
73
73
|
|
|
74
74
|
// calculate all vertices
|
|
75
75
|
for (i = 0; i < indices.length; i++ ) {
|
|
76
|
-
|
|
76
|
+
let point = points[indices[i]];
|
|
77
77
|
vertices[i].set(point.x, point.y);
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -115,11 +115,11 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
115
115
|
* @param {boolean} [anticlockwise=false] - an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
|
|
116
116
|
*/
|
|
117
117
|
arc(x, y, radius, startAngle, endAngle, anticlockwise = false) {
|
|
118
|
-
|
|
118
|
+
let points = this.points;
|
|
119
119
|
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
120
120
|
//bring angles all in [0, 2*PI] range
|
|
121
121
|
if (startAngle === endAngle) return;
|
|
122
|
-
|
|
122
|
+
const fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
123
123
|
|
|
124
124
|
startAngle = startAngle % (TAU);
|
|
125
125
|
endAngle = endAngle % (TAU);
|
|
@@ -131,8 +131,8 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
131
131
|
endAngle+= TAU;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
let diff = endAngle - startAngle;
|
|
135
|
+
let direction = 1;
|
|
136
136
|
if (anticlockwise) {
|
|
137
137
|
direction = -1;
|
|
138
138
|
diff = TAU - diff;
|
|
@@ -140,12 +140,12 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
140
140
|
|
|
141
141
|
if (fullCircle) diff = TAU;
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const length = diff * radius;
|
|
144
|
+
const nr_of_interpolation_points = length / this.arcResolution;
|
|
145
|
+
const dangle = diff / nr_of_interpolation_points;
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
for (
|
|
147
|
+
let angle = startAngle;
|
|
148
|
+
for (let j = 0; j < nr_of_interpolation_points; j++) {
|
|
149
149
|
points.push(pool.pull("Point", x + radius * Math.cos(angle), y + radius * Math.sin(angle)));
|
|
150
150
|
angle += direction * dangle;
|
|
151
151
|
}
|
|
@@ -161,40 +161,40 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
161
161
|
* @param {number} radius - the arc's radius. Must be positive.
|
|
162
162
|
*/
|
|
163
163
|
arcTo(x1, y1, x2, y2, radius) {
|
|
164
|
-
|
|
164
|
+
let points = this.points;
|
|
165
165
|
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
166
|
-
|
|
166
|
+
let x0 = points[points.length-1].x, y0 = points[points.length-1].y;
|
|
167
167
|
|
|
168
168
|
//a = -incoming vector, b = outgoing vector to x1, y1
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
let a0 = x0 - x1, a1 = y0 - y1;
|
|
170
|
+
let b0 = x2 - x1, b1 = y2 - y1;
|
|
171
171
|
|
|
172
172
|
//normalize
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
let l_a = Math.sqrt(Math.pow(a0, 2) + Math.pow(a1, 2));
|
|
174
|
+
let l_b = Math.sqrt(Math.pow(b0, 2) + Math.pow(b1, 2));
|
|
175
|
+
a0 /= l_a; a1 /= l_a; b0 /= l_b; b1 /= l_b;
|
|
176
|
+
let angle = Math.atan2(a1, a0) - Math.atan2(b1, b0);
|
|
177
177
|
|
|
178
178
|
//work out tangent points using tan(θ) = opposite / adjacent; angle/2 because hypotenuse is the bisection of a,b
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
let tan_angle_div2 = Math.tan(angle/2);
|
|
180
|
+
let adj_l = (radius/tan_angle_div2);
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
let tangent1_pointx = x1 + a0 * adj_l, tangent1_pointy = y1 + a1 * adj_l;
|
|
183
|
+
let tangent2_pointx = x1 + b0 * adj_l, tangent2_pointy = y1 + b1 * adj_l;
|
|
184
184
|
|
|
185
|
-
points.push(pool.pull("Point",
|
|
185
|
+
points.push(pool.pull("Point", tangent1_pointx, tangent1_pointy));
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
let bisec0 = (a0 + b0) / 2.0, bisec1 = (a1 + b1) / 2.0;
|
|
188
|
+
let bisec_l = Math.sqrt(Math.pow(bisec0, 2) + Math.pow(bisec1, 2));
|
|
189
|
+
bisec0 /= bisec_l; bisec1 /= bisec_l;
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
let hyp_l = Math.sqrt(Math.pow(radius, 2) + Math.pow(adj_l, 2));
|
|
192
|
+
let centerx = x1 + hyp_l * bisec0, centery = y1 + hyp_l * bisec1;
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
let startAngle = Math.atan2(tangent1_pointy - centery, tangent1_pointx - centerx);
|
|
195
|
+
let endAngle = Math.atan2(tangent2_pointy - centery, tangent2_pointx - centerx);
|
|
196
196
|
|
|
197
|
-
this.arc(
|
|
197
|
+
this.arc(centerx, centery, radius, startAngle, endAngle);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
@@ -210,10 +210,10 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
210
210
|
* @param {boolean} [anticlockwise=false] - an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
|
|
211
211
|
*/
|
|
212
212
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
213
|
-
|
|
213
|
+
let points = this.points;
|
|
214
214
|
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
215
215
|
if (startAngle === endAngle) return;
|
|
216
|
-
|
|
216
|
+
let fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
217
217
|
|
|
218
218
|
//bring angles all in [0, 2*PI] range
|
|
219
219
|
startAngle = startAngle % (TAU);
|
|
@@ -225,9 +225,9 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
225
225
|
endAngle += TAU;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
|
|
228
|
+
let diff = endAngle - startAngle;
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
let direction = 1;
|
|
231
231
|
if (anticlockwise) {
|
|
232
232
|
direction = -1;
|
|
233
233
|
diff = TAU - diff;
|
|
@@ -235,24 +235,21 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
235
235
|
|
|
236
236
|
if (fullCircle) diff = TAU;
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
for (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
238
|
+
const length = (diff * radiusX + diff * radiusY) / 2;
|
|
239
|
+
const nr_of_interpolation_points = length / this.arcResolution;
|
|
240
|
+
const dangle = diff / nr_of_interpolation_points;
|
|
241
|
+
|
|
242
|
+
let angle = startAngle;
|
|
243
|
+
const cos_rotation = Math.cos(rotation);
|
|
244
|
+
const sin_rotation = Math.sin(rotation);
|
|
245
|
+
for (let j = 0; j < nr_of_interpolation_points; j++) {
|
|
246
|
+
let _x1 = radiusX * Math.cos(angle);
|
|
247
|
+
let _y1 = radiusY * Math.sin(angle);
|
|
248
|
+
let _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
|
|
249
|
+
let _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
|
|
250
250
|
points.push(pool.pull("Point", _x2, _y2));
|
|
251
251
|
angle += direction * dangle;
|
|
252
252
|
}
|
|
253
|
-
//var x1 = radiusX * Math.cos(endAngle);
|
|
254
|
-
//var y1 = radiusY * Math.sin(endAngle);
|
|
255
|
-
//points.push(pool.pull("Point", x + x1 * cos_rotation - y1 * sin_rotation, y + x1 * sin_rotation + y1 * cos_rotation));
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
/**
|
|
@@ -265,8 +262,11 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
265
262
|
rect(x, y, width, height) {
|
|
266
263
|
this.moveTo(x, y);
|
|
267
264
|
this.lineTo(x + width, y);
|
|
265
|
+
this.moveTo(x + width, y);
|
|
268
266
|
this.lineTo(x + width, y + height);
|
|
267
|
+
this.moveTo(x + width, y + height);
|
|
269
268
|
this.lineTo(x, y + height);
|
|
269
|
+
this.moveTo(x, y + height);
|
|
270
270
|
this.lineTo(x, y);
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
* @returns {boolean}
|
|
59
59
|
*/
|
|
60
60
|
equals() {
|
|
61
|
-
|
|
61
|
+
let _x, _y;
|
|
62
62
|
if (arguments.length === 2) {
|
|
63
63
|
// x, y
|
|
64
64
|
_x = arguments[0];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -127,7 +127,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
127
127
|
|
|
128
128
|
} else {
|
|
129
129
|
// it's a flat array
|
|
130
|
-
for (
|
|
130
|
+
for (let p = 0; p < vertices.length; p += 2) {
|
|
131
131
|
this.points.push(pool.pull("Vector2d", vertices[p], vertices[p + 1]));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -149,9 +149,9 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
149
149
|
* @returns {Polygon} Reference to this object for method chaining
|
|
150
150
|
*/
|
|
151
151
|
transform(m) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
for (
|
|
152
|
+
let points = this.points;
|
|
153
|
+
let len = points.length;
|
|
154
|
+
for (let i = 0; i < len; i++) {
|
|
155
155
|
m.apply(points[i]);
|
|
156
156
|
}
|
|
157
157
|
this.recalc();
|
|
@@ -189,9 +189,9 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
189
189
|
*/
|
|
190
190
|
rotate(angle, v) {
|
|
191
191
|
if (angle !== 0) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
for (
|
|
192
|
+
let points = this.points;
|
|
193
|
+
let len = points.length;
|
|
194
|
+
for (let i = 0; i < len; i++) {
|
|
195
195
|
points[i].rotate(angle, v);
|
|
196
196
|
}
|
|
197
197
|
this.recalc();
|
|
@@ -209,9 +209,9 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
209
209
|
* @returns {Polygon} Reference to this object for method chaining
|
|
210
210
|
*/
|
|
211
211
|
scale(x, y = x) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
for (
|
|
212
|
+
let points = this.points;
|
|
213
|
+
let len = points.length;
|
|
214
|
+
for (let i = 0; i < len; i++) {
|
|
215
215
|
points[i].scale(x, y);
|
|
216
216
|
}
|
|
217
217
|
this.recalc();
|
|
@@ -238,14 +238,14 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
238
238
|
* @returns {Polygon} Reference to this object for method chaining
|
|
239
239
|
*/
|
|
240
240
|
recalc() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
let i;
|
|
242
|
+
let edges = this.edges;
|
|
243
|
+
let normals = this.normals;
|
|
244
|
+
let indices = this.indices;
|
|
245
245
|
|
|
246
246
|
// Copy the original points array and apply the offset/angle
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
let points = this.points;
|
|
248
|
+
let len = points.length;
|
|
249
249
|
|
|
250
250
|
if (len < 3) {
|
|
251
251
|
throw new Error("Requires at least 3 points");
|
|
@@ -297,7 +297,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
297
297
|
// http://paulbourke.net/geometry/polygonmesh/
|
|
298
298
|
// Copyright (c) Paul Bourke (use permitted)
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
let flag = 0,
|
|
301
301
|
vertices = this.points,
|
|
302
302
|
n = vertices.length,
|
|
303
303
|
i,
|
|
@@ -350,7 +350,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
350
350
|
* @returns {Polygon} Reference to this object for method chaining
|
|
351
351
|
*/
|
|
352
352
|
translate() {
|
|
353
|
-
|
|
353
|
+
let _x, _y;
|
|
354
354
|
|
|
355
355
|
if (arguments.length === 2) {
|
|
356
356
|
// x, y
|
|
@@ -384,7 +384,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
384
384
|
* @param {number} y
|
|
385
385
|
*/
|
|
386
386
|
shift() {
|
|
387
|
-
|
|
387
|
+
let _x, _y;
|
|
388
388
|
if (arguments.length === 2) {
|
|
389
389
|
// x, y
|
|
390
390
|
_x = arguments[0];
|
|
@@ -421,7 +421,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
421
421
|
* @returns {boolean} true if contains
|
|
422
422
|
*/
|
|
423
423
|
contains() {
|
|
424
|
-
|
|
424
|
+
let _x, _y;
|
|
425
425
|
|
|
426
426
|
if (arguments.length === 2) {
|
|
427
427
|
// x, y
|
|
@@ -433,14 +433,14 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
433
433
|
_y = arguments[0].y;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
436
|
+
let intersects = false;
|
|
437
|
+
let posx = this.pos.x, posy = this.pos.y;
|
|
438
|
+
let points = this.points;
|
|
439
|
+
let len = points.length;
|
|
440
440
|
|
|
441
441
|
//http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
|
442
|
-
for (
|
|
443
|
-
|
|
442
|
+
for (let i = 0, j = len - 1; i < len; j = i++) {
|
|
443
|
+
let iy = points[i].y + posy, ix = points[i].x + posx,
|
|
444
444
|
jy = points[j].y + posy, jx = points[j].x + posx;
|
|
445
445
|
if (((iy > _y) !== (jy > _y)) && (_x < (jx - ix) * (_y - iy) / (jy - iy) + ix)) {
|
|
446
446
|
intersects = !intersects;
|
|
@@ -469,7 +469,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
469
469
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
470
470
|
*/
|
|
471
471
|
updateBounds() {
|
|
472
|
-
|
|
472
|
+
let bounds = this.getBounds();
|
|
473
473
|
|
|
474
474
|
bounds.update(this.points);
|
|
475
475
|
bounds.translate(this.pos);
|
|
@@ -484,7 +484,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
484
484
|
* @returns {Polygon} new Polygon
|
|
485
485
|
*/
|
|
486
486
|
clone() {
|
|
487
|
-
|
|
487
|
+
let copy = [];
|
|
488
488
|
this.points.forEach((point) => {
|
|
489
489
|
copy.push(point.clone());
|
|
490
490
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -47,7 +47,7 @@ import Polygon from './poly.js';
|
|
|
47
47
|
* @returns {Rect} this rectangle
|
|
48
48
|
*/
|
|
49
49
|
setShape(x, y, w, h) {
|
|
50
|
-
|
|
50
|
+
let points = w; // assume w is an array by default
|
|
51
51
|
|
|
52
52
|
this.pos.set(x, y);
|
|
53
53
|
|
|
@@ -83,7 +83,7 @@ import Polygon from './poly.js';
|
|
|
83
83
|
* @memberof Rect
|
|
84
84
|
*/
|
|
85
85
|
get right() {
|
|
86
|
-
|
|
86
|
+
let w = this.width;
|
|
87
87
|
return (this.left + w) || w;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -106,7 +106,7 @@ import Polygon from './poly.js';
|
|
|
106
106
|
* @memberof Rect
|
|
107
107
|
*/
|
|
108
108
|
get bottom() {
|
|
109
|
-
|
|
109
|
+
let h = this.height;
|
|
110
110
|
return (this.top + h) || h;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -253,8 +253,8 @@ import Polygon from './poly.js';
|
|
|
253
253
|
* @returns {Rect} the union(ed) rectangle
|
|
254
254
|
*/
|
|
255
255
|
union(rect) {
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
let x1 = Math.min(this.left, rect.left);
|
|
257
|
+
let y1 = Math.min(this.top, rect.top);
|
|
258
258
|
|
|
259
259
|
this.resize(
|
|
260
260
|
Math.max(this.right, rect.right) - x1,
|
|
@@ -309,8 +309,8 @@ import Polygon from './poly.js';
|
|
|
309
309
|
* @returns {boolean} true if contains
|
|
310
310
|
*/
|
|
311
311
|
contains() {
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
let arg0 = arguments[0];
|
|
313
|
+
let _x1, _x2, _y1, _y2;
|
|
314
314
|
if (arguments.length === 2) {
|
|
315
315
|
// x, y
|
|
316
316
|
_x1 = _x2 = arg0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -90,8 +90,8 @@ class RoundRect extends Rect {
|
|
|
90
90
|
* @returns {boolean} true if contains
|
|
91
91
|
*/
|
|
92
92
|
contains() {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
let arg0 = arguments[0];
|
|
94
|
+
let _x, _y;
|
|
95
95
|
if (arguments.length === 2) {
|
|
96
96
|
// x, y
|
|
97
97
|
_x = arg0;
|
|
@@ -118,9 +118,9 @@ class RoundRect extends Rect {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
// check whether point is in one of the rounded corner areas
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
let tx, ty;
|
|
122
|
+
const radiusX = Math.max(0, Math.min(this.radius, this.width / 2));
|
|
123
|
+
const radiusY = Math.max(0, Math.min(this.radius, this.height / 2));
|
|
124
124
|
|
|
125
125
|
if (_x < this.left + radiusX && _y < this.top + radiusY) {
|
|
126
126
|
tx = _x - this.left - radiusX;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -23,7 +23,9 @@ export { default as Body } from './physics/body.js';
|
|
|
23
23
|
import Bounds from './physics/bounds.js';
|
|
24
24
|
import Tween from './tweens/tween.js';
|
|
25
25
|
export { default as GLShader } from './video/webgl/glshader.js';
|
|
26
|
-
export { default as
|
|
26
|
+
export { default as Compositor } from './video/webgl/compositors/compositor.js';
|
|
27
|
+
export { default as PrimitiveCompositor } from './video/webgl/compositors/primitive_compositor.js';
|
|
28
|
+
export { default as QuadCompositor } from './video/webgl/compositors/quad_compositor.js';
|
|
27
29
|
export { default as Renderer } from './video/renderer.js';
|
|
28
30
|
export { default as WebGLRenderer } from './video/webgl/webgl_renderer.js';
|
|
29
31
|
export { default as CanvasRenderer } from './video/canvas/canvas_renderer.js';
|
|
@@ -103,7 +105,7 @@ import { initKeyboardEvent } from './input/keyboard.js';
|
|
|
103
105
|
* @name version
|
|
104
106
|
* @type {string}
|
|
105
107
|
*/
|
|
106
|
-
const version = "
|
|
108
|
+
const version = "15.1.0";
|
|
107
109
|
|
|
108
110
|
/**
|
|
109
111
|
* a flag indicating that melonJS is fully initialized
|
|
@@ -111,7 +113,7 @@ const version = "14.5.0";
|
|
|
111
113
|
* @default false
|
|
112
114
|
* @readonly
|
|
113
115
|
*/
|
|
114
|
-
|
|
116
|
+
let initialized = false;
|
|
115
117
|
|
|
116
118
|
/**
|
|
117
119
|
* disable melonJS auto-initialization
|
|
@@ -119,7 +121,7 @@ var initialized = false;
|
|
|
119
121
|
* @default false
|
|
120
122
|
* @see boot
|
|
121
123
|
*/
|
|
122
|
-
|
|
124
|
+
let skipAutoInit = false;
|
|
123
125
|
|
|
124
126
|
/*
|
|
125
127
|
* game is a default instance of a melonJS Application and represents your current game,
|
|
@@ -227,4 +229,4 @@ onReady(() => {
|
|
|
227
229
|
}
|
|
228
230
|
});
|
|
229
231
|
|
|
230
|
-
export { Application, BitmapText, BitmapTextData, Bounds, Collectable, Color, ColorLayer, Ellipse, Entity, ImageLayer, Light2d, Line, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, Point, Polygon, Rect, Renderable, RoundRect, Sprite, Text, Trigger, Tween, Vector2d, Vector3d, boot, game, initialized, pool, skipAutoInit, utils, version };
|
|
232
|
+
export { Application, BitmapText, BitmapTextData, Bounds, CanvasTexture, Collectable, Color, ColorLayer, Ellipse, Entity, ImageLayer, Light2d, Line, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, Point, Polygon, Rect, Renderable, RoundRect, Sprite, Text, Trigger, Tween, Vector2d, Vector3d, boot, game, initialized, pool, skipAutoInit, utils, version };
|