melonjs 15.0.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/README.md +4 -4
- 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 +17 -17
- 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 +53 -53
- 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 +5 -5
- 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 +58 -58
- 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 +21 -21
- 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 +11 -11
- 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 -63
- 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 +2 -2
- 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 +10 -9
- package/dist/melonjs.mjs/text/textmetrics.js +15 -15
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- 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 +35 -109
- package/dist/melonjs.mjs/video/renderer.js +74 -7
- package/dist/melonjs.mjs/video/texture/atlas.js +37 -37
- 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 +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +18 -15
- 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 +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 +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 +55 -38
- package/dist/melonjs.module.js +1747 -1809
- package/dist/types/application/application.d.ts +11 -8
- package/dist/types/audio/audio.d.ts +3 -3
- package/dist/types/index.d.ts +4 -3
- 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/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 -11
- 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 +1 -1
- package/dist/types/utils/array.d.ts +2 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +8 -76
- package/dist/types/video/renderer.d.ts +48 -0
- 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/glshader.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +13 -9
- package/package.json +14 -14
- 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 +16 -16
- 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 +52 -52
- 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 +3 -2
- 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 +20 -20
- 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/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 +10 -10
- 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 -65
- package/src/state/stage.js +6 -6
- package/src/state/state.js +14 -14
- package/src/system/device.js +1 -1
- 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 +9 -8
- package/src/text/textmetrics.js +14 -14
- 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 +34 -108
- package/src/video/renderer.js +72 -5
- package/src/video/texture/atlas.js +36 -36
- 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 +2 -2
- package/src/video/webgl/compositors/compositor.js +4 -4
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +17 -14
- package/src/video/webgl/glshader.js +6 -6
- 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 +54 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
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
|
|
@@ -18,7 +18,7 @@ import { remove } from '../utils/array.js';
|
|
|
18
18
|
* a pool of `QuadTree` objects
|
|
19
19
|
* @ignore
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
let QT_ARRAY = [];
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* will pop a quadtree object from the array
|
|
@@ -27,7 +27,7 @@ var QT_ARRAY = [];
|
|
|
27
27
|
*/
|
|
28
28
|
function QT_ARRAY_POP(world, bounds, max_objects = 4, max_levels = 4, level = 0) {
|
|
29
29
|
if (QT_ARRAY.length > 0) {
|
|
30
|
-
|
|
30
|
+
let _qt = QT_ARRAY.pop();
|
|
31
31
|
_qt.world = world;
|
|
32
32
|
_qt.bounds = bounds;
|
|
33
33
|
_qt.max_objects = max_objects;
|
|
@@ -51,7 +51,7 @@ function QT_ARRAY_PUSH(qt) {
|
|
|
51
51
|
* a temporary vector object to be reused
|
|
52
52
|
* @ignore
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
let QT_VECTOR = new Vector2d();
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* @classdesc
|
|
@@ -84,7 +84,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
84
84
|
* Split the node into 4 subnodes
|
|
85
85
|
*/
|
|
86
86
|
split() {
|
|
87
|
-
|
|
87
|
+
let nextLevel = this.level + 1,
|
|
88
88
|
subWidth = this.bounds.width / 2,
|
|
89
89
|
subHeight = this.bounds.height / 2,
|
|
90
90
|
left = this.bounds.left,
|
|
@@ -153,8 +153,8 @@ var QT_VECTOR = new Vector2d();
|
|
|
153
153
|
* @returns Integer index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node
|
|
154
154
|
*/
|
|
155
155
|
getIndex(item) {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
let pos;
|
|
157
|
+
let bounds = item.getBounds();
|
|
158
158
|
|
|
159
159
|
// use game world coordinates for floating items
|
|
160
160
|
if (item.isFloating === true) {
|
|
@@ -163,7 +163,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
163
163
|
pos = QT_VECTOR.set(item.left, item.top);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
let index = -1,
|
|
167
167
|
rx = pos.x,
|
|
168
168
|
ry = pos.y,
|
|
169
169
|
rw = bounds.width,
|
|
@@ -201,7 +201,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
201
201
|
* @param {Container} container - group of objects to be added
|
|
202
202
|
*/
|
|
203
203
|
insertContainer(container) {
|
|
204
|
-
for (
|
|
204
|
+
for (let i = container.children.length, child; i--, (child = container.children[i]);) {
|
|
205
205
|
if (child.isKinematic !== true) {
|
|
206
206
|
if (typeof child.addChild === "function") {
|
|
207
207
|
if (child.name !== "rootContainer") {
|
|
@@ -229,7 +229,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
229
229
|
* @param {object} item - object to be added
|
|
230
230
|
*/
|
|
231
231
|
insert(item) {
|
|
232
|
-
|
|
232
|
+
let index = -1;
|
|
233
233
|
|
|
234
234
|
//if we have subnodes ...
|
|
235
235
|
if (this.nodes.length > 0) {
|
|
@@ -250,7 +250,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
250
250
|
this.split();
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
let i = 0;
|
|
254
254
|
|
|
255
255
|
//add all objects to there corresponding subnodes
|
|
256
256
|
while (i < this.objects.length) {
|
|
@@ -275,19 +275,19 @@ var QT_VECTOR = new Vector2d();
|
|
|
275
275
|
* @returns {object[]} array with all detected objects
|
|
276
276
|
*/
|
|
277
277
|
retrieve(item, fn) {
|
|
278
|
-
|
|
278
|
+
let returnObjects = this.objects;
|
|
279
279
|
|
|
280
280
|
//if we have subnodes ...
|
|
281
281
|
if (this.nodes.length > 0) {
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
let index = this.getIndex(item);
|
|
284
284
|
|
|
285
285
|
//if rect fits into a subnode ..
|
|
286
286
|
if (index !== -1) {
|
|
287
287
|
returnObjects = returnObjects.concat(this.nodes[index].retrieve(item));
|
|
288
288
|
} else {
|
|
289
289
|
//if rect does not fit into a subnode, check it against all subnodes
|
|
290
|
-
for (
|
|
290
|
+
for (let i = 0; i < this.nodes.length; i = i + 1) {
|
|
291
291
|
returnObjects = returnObjects.concat(this.nodes[i].retrieve(item));
|
|
292
292
|
}
|
|
293
293
|
}
|
|
@@ -309,7 +309,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
309
309
|
* @returns {boolean} true if the item was found and removed.
|
|
310
310
|
*/
|
|
311
311
|
remove(item) {
|
|
312
|
-
|
|
312
|
+
let found = false;
|
|
313
313
|
|
|
314
314
|
if (typeof (item.getBounds) === "undefined") {
|
|
315
315
|
// ignore object that cannot be added in the first place
|
|
@@ -319,7 +319,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
319
319
|
//if we have subnodes ...
|
|
320
320
|
if (this.nodes.length > 0) {
|
|
321
321
|
// determine to which node the item belongs to
|
|
322
|
-
|
|
322
|
+
let index = this.getIndex(item);
|
|
323
323
|
|
|
324
324
|
if (index !== -1) {
|
|
325
325
|
found = remove(this.nodes[index], item);
|
|
@@ -358,8 +358,8 @@ var QT_VECTOR = new Vector2d();
|
|
|
358
358
|
* @returns {boolean} true if the node has any children
|
|
359
359
|
*/
|
|
360
360
|
hasChildren() {
|
|
361
|
-
for (
|
|
362
|
-
|
|
361
|
+
for (let i = 0; i < this.nodes.length; i = i + 1) {
|
|
362
|
+
let subnode = this.nodes[i];
|
|
363
363
|
if (subnode.length > 0 || subnode.objects.length > 0) {
|
|
364
364
|
return true;
|
|
365
365
|
}
|
|
@@ -376,7 +376,7 @@ var QT_VECTOR = new Vector2d();
|
|
|
376
376
|
clear(bounds) {
|
|
377
377
|
this.objects.length = 0;
|
|
378
378
|
|
|
379
|
-
for (
|
|
379
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
380
380
|
this.nodes[i].clear();
|
|
381
381
|
// recycle the quadTree object
|
|
382
382
|
QT_ARRAY_PUSH(this.nodes[i]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
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
|
|
@@ -36,16 +36,16 @@ const RIGHT_VORNOI_REGION = 1;
|
|
|
36
36
|
* @type {Array.<Vector2d>}
|
|
37
37
|
* @ignore
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
for (
|
|
39
|
+
let T_VECTORS = [];
|
|
40
|
+
for (let v = 0; v < 10; v++) { T_VECTORS.push(new Vector2d()); }
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* A pool of arrays of numbers used in calculations to avoid allocating memory.
|
|
44
44
|
* @type {Array.<Array.<number>>}
|
|
45
45
|
* @ignore
|
|
46
46
|
*/
|
|
47
|
-
|
|
48
|
-
for (
|
|
47
|
+
let T_ARRAYS = [];
|
|
48
|
+
for (let a = 0; a < 5; a++) { T_ARRAYS.push([]); }
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -60,12 +60,12 @@ for (var a = 0; a < 5; a++) { T_ARRAYS.push([]); }
|
|
|
60
60
|
* result[1] will be the maximum value.
|
|
61
61
|
*/
|
|
62
62
|
function flattenPointsOn(points, normal, result) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
for (
|
|
63
|
+
let min = Number.MAX_VALUE;
|
|
64
|
+
let max = -Number.MAX_VALUE;
|
|
65
|
+
let len = points.length;
|
|
66
|
+
for (let i = 0; i < len; i++) {
|
|
67
67
|
// The magnitude of the projection of the point onto the normal
|
|
68
|
-
|
|
68
|
+
let dot = points[i].dot(normal);
|
|
69
69
|
if (dot < min) { min = dot; }
|
|
70
70
|
if (dot > max) { max = dot; }
|
|
71
71
|
}
|
|
@@ -90,11 +90,11 @@ function flattenPointsOn(points, normal, result) {
|
|
|
90
90
|
* the direction of the overlap will be populated.
|
|
91
91
|
*/
|
|
92
92
|
function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
let rangeA = T_ARRAYS.pop();
|
|
94
|
+
let rangeB = T_ARRAYS.pop();
|
|
95
95
|
// The magnitude of the offset between the two polygons
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
let offsetV = T_VECTORS.pop().copy(bPos).sub(aPos);
|
|
97
|
+
let projectedOffset = offsetV.dot(axis);
|
|
98
98
|
|
|
99
99
|
// Project the polygons onto the axis.
|
|
100
100
|
flattenPointsOn(aPoints, axis, rangeA);
|
|
@@ -112,7 +112,7 @@ function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
|
112
112
|
|
|
113
113
|
// This is not a separating axis. If we're calculating a response, calculate the overlap.
|
|
114
114
|
if (response) {
|
|
115
|
-
|
|
115
|
+
let overlap = 0;
|
|
116
116
|
// A starts further left than B
|
|
117
117
|
if (rangeA[0] < rangeB[0]) {
|
|
118
118
|
response.aInB = false;
|
|
@@ -122,8 +122,8 @@ function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
|
122
122
|
response.bInA = false;
|
|
123
123
|
// B is fully inside A. Pick the shortest way out.
|
|
124
124
|
} else {
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
let option1 = rangeA[1] - rangeB[0];
|
|
126
|
+
let option2 = rangeB[1] - rangeA[0];
|
|
127
127
|
overlap = option1 < option2 ? option1 : -option2;
|
|
128
128
|
}
|
|
129
129
|
// B starts further left than A
|
|
@@ -135,14 +135,14 @@ function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
|
135
135
|
response.aInB = false;
|
|
136
136
|
// A is fully inside B. Pick the shortest way out.
|
|
137
137
|
} else {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
let option11 = rangeA[1] - rangeB[0];
|
|
139
|
+
let option22 = rangeB[1] - rangeA[0];
|
|
140
140
|
overlap = option11 < option22 ? option11 : -option22;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// If this is the smallest amount of overlap we've seen so far, set it as the minimum overlap.
|
|
145
|
-
|
|
145
|
+
let absOverlap = Math.abs(overlap);
|
|
146
146
|
if (absOverlap < response.overlap) {
|
|
147
147
|
response.overlap = absOverlap;
|
|
148
148
|
response.overlapN.copy(axis);
|
|
@@ -175,8 +175,8 @@ function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
|
175
175
|
* RIGHT_VORNOI_REGION (1) if it is the right region.
|
|
176
176
|
*/
|
|
177
177
|
function vornoiRegion(line, point) {
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
let len2 = line.length2();
|
|
179
|
+
let dp = point.dot(line);
|
|
180
180
|
if (dp < 0) {
|
|
181
181
|
// If the point is beyond the start of the line, it is in the
|
|
182
182
|
// left vornoi region.
|
|
@@ -203,16 +203,16 @@ function vornoiRegion(line, point) {
|
|
|
203
203
|
*/
|
|
204
204
|
function testPolygonPolygon(a, polyA, b, polyB, response) {
|
|
205
205
|
// specific point for
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
let aPoints = polyA.points;
|
|
207
|
+
let aNormals = polyA.normals;
|
|
208
|
+
let aLen = aNormals.length;
|
|
209
|
+
let bPoints = polyB.points;
|
|
210
|
+
let bNormals = polyB.normals;
|
|
211
|
+
let bLen = bNormals.length;
|
|
212
212
|
// aboslute shape position
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
let posA = T_VECTORS.pop().copy(a.pos).add(a.ancestor.getAbsolutePosition()).add(polyA.pos);
|
|
214
|
+
let posB = T_VECTORS.pop().copy(b.pos).add(b.ancestor.getAbsolutePosition()).add(polyB.pos);
|
|
215
|
+
let i;
|
|
216
216
|
|
|
217
217
|
// If any of the edge normals of A is a separating axis, no intersection.
|
|
218
218
|
for (i = 0; i < aLen; i++) {
|
|
@@ -259,13 +259,13 @@ function testPolygonPolygon(a, polyA, b, polyB, response) {
|
|
|
259
259
|
function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
|
|
260
260
|
// Check if the distance between the centers of the two
|
|
261
261
|
// circles is greater than their combined radius.
|
|
262
|
-
|
|
262
|
+
let differenceV = T_VECTORS.pop().copy(b.pos).add(b.ancestor.getAbsolutePosition()).add(ellipseB.pos)
|
|
263
263
|
.sub(a.pos).add(a.ancestor.getAbsolutePosition()).sub(ellipseA.pos);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
264
|
+
let radiusA = ellipseA.radius;
|
|
265
|
+
let radiusB = ellipseB.radius;
|
|
266
|
+
let totalRadius = radiusA + radiusB;
|
|
267
|
+
let totalRadiusSq = totalRadius * totalRadius;
|
|
268
|
+
let distanceSq = differenceV.length2();
|
|
269
269
|
// If the distance is bigger than the combined radius, they don't intersect.
|
|
270
270
|
if (distanceSq > totalRadiusSq) {
|
|
271
271
|
T_VECTORS.push(differenceV);
|
|
@@ -273,7 +273,7 @@ function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
|
|
|
273
273
|
}
|
|
274
274
|
// They intersect. If we're calculating a response, calculate the overlap.
|
|
275
275
|
if (response) {
|
|
276
|
-
|
|
276
|
+
let dist = Math.sqrt(distanceSq);
|
|
277
277
|
response.a = a;
|
|
278
278
|
response.b = b;
|
|
279
279
|
response.overlap = totalRadius - dist;
|
|
@@ -298,24 +298,24 @@ function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
|
|
|
298
298
|
*/
|
|
299
299
|
function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
300
300
|
// Get the position of the circle relative to the polygon.
|
|
301
|
-
|
|
301
|
+
let circlePos = T_VECTORS.pop().copy(b.pos).add(b.ancestor.getAbsolutePosition()).add(ellipseB.pos)
|
|
302
302
|
.sub(a.pos).add(a.ancestor.getAbsolutePosition()).sub(polyA.pos);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
303
|
+
let radius = ellipseB.radius;
|
|
304
|
+
let radius2 = radius * radius;
|
|
305
|
+
let points = polyA.points;
|
|
306
|
+
let edges = polyA.edges;
|
|
307
|
+
let len = edges.length;
|
|
308
|
+
let edge = T_VECTORS.pop();
|
|
309
|
+
let normal = T_VECTORS.pop();
|
|
310
|
+
let point = T_VECTORS.pop();
|
|
311
|
+
let dist = 0;
|
|
312
312
|
|
|
313
313
|
// For each edge in the polygon:
|
|
314
|
-
for (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
314
|
+
for (let i = 0; i < len; i++) {
|
|
315
|
+
let next = i === len - 1 ? 0 : i + 1;
|
|
316
|
+
let prev = i === 0 ? len - 1 : i - 1;
|
|
317
|
+
let overlap = 0;
|
|
318
|
+
let overlapN = null;
|
|
319
319
|
|
|
320
320
|
// Get the edge.
|
|
321
321
|
edge.copy(edges[i]);
|
|
@@ -330,11 +330,11 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
// Calculate which Vornoi region the center of the circle is in.
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
let region = vornoiRegion(edge, point);
|
|
334
|
+
let inRegion = true;
|
|
335
335
|
// If it's the left region:
|
|
336
336
|
if (region === LEFT_VORNOI_REGION) {
|
|
337
|
-
|
|
337
|
+
let point2 = null;
|
|
338
338
|
if (len > 1) {
|
|
339
339
|
// We need to make sure we're in the RIGHT_VORNOI_REGION of the previous edge.
|
|
340
340
|
edge.copy(edges[prev]);
|
|
@@ -408,7 +408,7 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
408
408
|
// Find the perpendicular distance between the center of the
|
|
409
409
|
// circle and the edge.
|
|
410
410
|
dist = point.dot(normal);
|
|
411
|
-
|
|
411
|
+
let distAbs = Math.abs(dist);
|
|
412
412
|
// If the circle is on the outside of the edge, there is no intersection.
|
|
413
413
|
if ((len === 1 || dist > 0) && distAbs > radius) {
|
|
414
414
|
// No intersection
|
|
@@ -465,11 +465,11 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
465
465
|
*/
|
|
466
466
|
function testEllipsePolygon(a, ellipseA, b, polyB, response) {
|
|
467
467
|
// Test the polygon against the circle.
|
|
468
|
-
|
|
468
|
+
let result = testPolygonEllipse(b, polyB, a, ellipseA, response);
|
|
469
469
|
if (result && response) {
|
|
470
470
|
// Swap A and B in the response.
|
|
471
|
-
|
|
472
|
-
|
|
471
|
+
let resa = response.a;
|
|
472
|
+
let aInB = response.aInB;
|
|
473
473
|
response.overlapN.negateSelf();
|
|
474
474
|
response.overlapV.negateSelf();
|
|
475
475
|
response.a = response.b;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
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
|
|
@@ -147,7 +147,7 @@ import state from '../state/state.js';
|
|
|
147
147
|
bodyApplyGravity(body) {
|
|
148
148
|
// apply gravity to the current velocity
|
|
149
149
|
if (!body.ignoreGravity && body.gravityScale !== 0) {
|
|
150
|
-
|
|
150
|
+
let gravity = this.gravity;
|
|
151
151
|
|
|
152
152
|
// apply gravity if defined
|
|
153
153
|
body.force.x += (body.mass * gravity.x) * body.gravityScale;
|
|
@@ -161,7 +161,7 @@ import state from '../state/state.js';
|
|
|
161
161
|
* @returns {boolean} true if the word is dirty
|
|
162
162
|
*/
|
|
163
163
|
update(dt) {
|
|
164
|
-
|
|
164
|
+
let isPaused = state.isPaused();
|
|
165
165
|
|
|
166
166
|
// clear the quadtree
|
|
167
167
|
this.broadphase.clear();
|
|
@@ -172,7 +172,7 @@ import state from '../state/state.js';
|
|
|
172
172
|
// iterate through all bodies
|
|
173
173
|
this.bodies.forEach((body) => {
|
|
174
174
|
if (!body.isStatic) {
|
|
175
|
-
|
|
175
|
+
let ancestor = body.ancestor;
|
|
176
176
|
// if the game is not paused, and ancestor can be updated
|
|
177
177
|
if (!(isPaused && (!ancestor.updateWhenPaused)) &&
|
|
178
178
|
(ancestor.inViewport || ancestor.alwaysUpdate)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
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
|
|
@@ -13,7 +13,7 @@ import { version } from '../index.js';
|
|
|
13
13
|
* @see plugin.register
|
|
14
14
|
* @namespace plugins
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
let plugins = {};
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class BasePlugin {
|
|
@@ -24,17 +24,17 @@ class BasePlugin {
|
|
|
24
24
|
* this can be overridden by the plugin
|
|
25
25
|
* @public
|
|
26
26
|
* @type {string}
|
|
27
|
-
* @default "15.
|
|
27
|
+
* @default "15.1.0"
|
|
28
28
|
* @name plugin.Base#version
|
|
29
29
|
*/
|
|
30
|
-
this.version = "15.
|
|
30
|
+
this.version = "15.1.0";
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @namespace plugin
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
let plugin = {
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* a base Object for plugin <br>
|
|
@@ -71,14 +71,14 @@ var plugin = {
|
|
|
71
71
|
// reuse the logic behind object extends
|
|
72
72
|
if (typeof(proto[name]) === "function") {
|
|
73
73
|
// save the original function
|
|
74
|
-
|
|
74
|
+
let _parent = proto[name];
|
|
75
75
|
// override the function with the new one
|
|
76
76
|
Object.defineProperty(proto, name, {
|
|
77
77
|
"configurable" : true,
|
|
78
78
|
"value" : (function (name, fn) {
|
|
79
79
|
return function () {
|
|
80
80
|
this._patched = _parent;
|
|
81
|
-
|
|
81
|
+
let ret = fn.apply(this, arguments);
|
|
82
82
|
this._patched = null;
|
|
83
83
|
return ret;
|
|
84
84
|
};
|
|
@@ -97,7 +97,7 @@ var plugin = {
|
|
|
97
97
|
* @see Base
|
|
98
98
|
* @public
|
|
99
99
|
* @param {plugin.Base} pluginObj - Plugin object to instantiate and register
|
|
100
|
-
* @param {string} name
|
|
100
|
+
* @param {string} [name=pluginObj.constructor.name] - a unique name for this plugin
|
|
101
101
|
* @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
|
|
102
102
|
* @example
|
|
103
103
|
* // register a new plugin
|
|
@@ -106,14 +106,14 @@ var plugin = {
|
|
|
106
106
|
* // under then me.plugins namespace
|
|
107
107
|
* me.plugins.testPlugin.myfunction ();
|
|
108
108
|
*/
|
|
109
|
-
register : function (pluginObj, name) {
|
|
109
|
+
register : function (pluginObj, name = pluginObj.toString().match(/ (\w+)/)[1]) {
|
|
110
110
|
// ensure me.plugins[name] is not already "used"
|
|
111
111
|
if (plugins[name]) {
|
|
112
112
|
throw new Error("plugin " + name + " already registered");
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// get extra arguments
|
|
116
|
-
|
|
116
|
+
let _args = [];
|
|
117
117
|
if (arguments.length > 2) {
|
|
118
118
|
// store extra arguments if any
|
|
119
119
|
_args = Array.prototype.slice.call(arguments, 1);
|
|
@@ -121,7 +121,7 @@ var plugin = {
|
|
|
121
121
|
|
|
122
122
|
// try to instantiate the plugin
|
|
123
123
|
_args[0] = pluginObj;
|
|
124
|
-
|
|
124
|
+
let instance = new (pluginObj.bind.apply(pluginObj, _args))();
|
|
125
125
|
|
|
126
126
|
// inheritance check
|
|
127
127
|
if (typeof instance === "undefined" || !(instance instanceof plugin.Base)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
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
|
|
@@ -31,7 +31,7 @@ import pool from '../system/pooling.js';
|
|
|
31
31
|
this.id = settings.id;
|
|
32
32
|
|
|
33
33
|
// add and configure the physic body
|
|
34
|
-
|
|
34
|
+
let shape = settings.shapes;
|
|
35
35
|
if (typeof shape === "undefined") {
|
|
36
36
|
shape = pool.pull("Polygon", 0, 0, [
|
|
37
37
|
pool.pull("Vector2d", 0, 0),
|