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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
|
+
* http://www.melonjs.org
|
|
4
|
+
* melonjs is licensed under the MIT License.
|
|
5
|
+
* http://www.opensource.org/licenses/mit-license
|
|
6
|
+
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
|
|
7
|
+
*/
|
|
8
|
+
class Multimap {
|
|
9
|
+
constructor(operator, iterable) {
|
|
10
|
+
this.size_ = 0;
|
|
11
|
+
this.map = new Map();
|
|
12
|
+
this.operator = operator;
|
|
13
|
+
if (iterable) {
|
|
14
|
+
for (const [key, value] of iterable) {
|
|
15
|
+
this.put(key, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
get size() {
|
|
21
|
+
return this.size_;
|
|
22
|
+
}
|
|
23
|
+
get(key) {
|
|
24
|
+
const values = this.map.get(key);
|
|
25
|
+
if (values) {
|
|
26
|
+
return this.operator.clone(values);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return this.operator.create();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
put(key, value) {
|
|
33
|
+
let values = this.map.get(key);
|
|
34
|
+
if (!values) {
|
|
35
|
+
values = this.operator.create();
|
|
36
|
+
}
|
|
37
|
+
if (!this.operator.add(value, values)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
this.map.set(key, values);
|
|
41
|
+
this.size_++;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
putAll(arg1, arg2) {
|
|
45
|
+
let pushed = 0;
|
|
46
|
+
if (arg2) {
|
|
47
|
+
const key = arg1;
|
|
48
|
+
const values = arg2;
|
|
49
|
+
for (const value of values) {
|
|
50
|
+
this.put(key, value);
|
|
51
|
+
pushed++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (arg1 instanceof Multimap) {
|
|
55
|
+
for (const [key, value] of arg1.entries()) {
|
|
56
|
+
this.put(key, value);
|
|
57
|
+
pushed++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new TypeError("unexpected arguments");
|
|
62
|
+
}
|
|
63
|
+
return pushed > 0;
|
|
64
|
+
}
|
|
65
|
+
has(key) {
|
|
66
|
+
return this.map.has(key);
|
|
67
|
+
}
|
|
68
|
+
hasEntry(key, value) {
|
|
69
|
+
return this.operator.has(value, this.get(key));
|
|
70
|
+
}
|
|
71
|
+
delete(key) {
|
|
72
|
+
this.size_ -= this.operator.size(this.get(key));
|
|
73
|
+
return this.map.delete(key);
|
|
74
|
+
}
|
|
75
|
+
deleteEntry(key, value) {
|
|
76
|
+
const current = this.get(key);
|
|
77
|
+
if (!this.operator.delete(value, current)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
this.map.set(key, current);
|
|
81
|
+
this.size_--;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
clear() {
|
|
85
|
+
this.map.clear();
|
|
86
|
+
this.size_ = 0;
|
|
87
|
+
}
|
|
88
|
+
keys() {
|
|
89
|
+
return this.map.keys();
|
|
90
|
+
}
|
|
91
|
+
entries() {
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
93
|
+
const self = this;
|
|
94
|
+
function* gen() {
|
|
95
|
+
for (const [key, values] of self.map.entries()) {
|
|
96
|
+
for (const value of values) {
|
|
97
|
+
yield [key, value];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return gen();
|
|
102
|
+
}
|
|
103
|
+
values() {
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
105
|
+
const self = this;
|
|
106
|
+
function* gen() {
|
|
107
|
+
for (const [, value] of self.entries()) {
|
|
108
|
+
yield value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return gen();
|
|
112
|
+
}
|
|
113
|
+
forEach(callback, thisArg) {
|
|
114
|
+
for (const [key, value] of this.entries()) {
|
|
115
|
+
callback.call(thisArg === undefined ? this : thisArg, value, key, this);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
[Symbol.iterator]() {
|
|
119
|
+
return this.entries();
|
|
120
|
+
}
|
|
121
|
+
asMap() {
|
|
122
|
+
const ret = new Map();
|
|
123
|
+
for (const key of this.keys()) {
|
|
124
|
+
ret.set(key, this.operator.clone(this.get(key)));
|
|
125
|
+
}
|
|
126
|
+
return ret;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { Multimap };
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
6
6
|
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
|
|
7
7
|
*/
|
|
8
|
-
import { __module as eventemitter3, exports as eventemitter3Exports } from '../../_virtual/
|
|
8
|
+
import { __module as eventemitter3, exports as eventemitter3Exports } from '../../_virtual/index.js';
|
|
9
9
|
|
|
10
10
|
(function (module) {
|
|
11
11
|
|
|
@@ -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
|
|
@@ -14,7 +14,7 @@ import Container from '../renderable/container.js';
|
|
|
14
14
|
* @ignore
|
|
15
15
|
*/
|
|
16
16
|
function createDefaultParticleTexture(w = 8, h = 8) {
|
|
17
|
-
|
|
17
|
+
let defaultParticleTexture = pool.pull("CanvasTexture", w, h, { offscreenCanvas: true });
|
|
18
18
|
|
|
19
19
|
defaultParticleTexture.context.fillStyle = "#fff";
|
|
20
20
|
defaultParticleTexture.context.fillRect(0, 0, w, h);
|
|
@@ -34,7 +34,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
|
|
|
34
34
|
* @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] - the settings for the particle emitter.
|
|
35
35
|
* @example
|
|
36
36
|
* // Create a particle emitter at position 100, 100
|
|
37
|
-
*
|
|
37
|
+
* let emitter = new ParticleEmitter(100, 100, {
|
|
38
38
|
* width: 16,
|
|
39
39
|
* height : 16,
|
|
40
40
|
* tint: "#f00",
|
|
@@ -150,7 +150,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
|
|
|
150
150
|
// Add count particles in the game world
|
|
151
151
|
/** @ignore */
|
|
152
152
|
addParticles(count) {
|
|
153
|
-
for (
|
|
153
|
+
for (let i = 0; i < count; i++) {
|
|
154
154
|
// Add particle to the container
|
|
155
155
|
this.addChild(pool.pull("Particle", this), this.pos.z);
|
|
156
156
|
}
|
|
@@ -230,7 +230,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
|
|
|
230
230
|
this._frequencyTimer += dt;
|
|
231
231
|
|
|
232
232
|
// Check for new particles launch
|
|
233
|
-
|
|
233
|
+
const particlesCount = this.children.length;
|
|
234
234
|
if ((particlesCount < this.settings.totalParticles) && (this._frequencyTimer >= this.settings.frequency)) {
|
|
235
235
|
if ((particlesCount + this.settings.maxParticles) <= this.settings.totalParticles) {
|
|
236
236
|
this.addParticles(this.settings.maxParticles);
|
|
@@ -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
|
|
@@ -67,8 +67,8 @@ import Renderable from '../renderable/renderable.js';
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Set the start particle Angle and Speed as defined in emitter
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
let angle = emitter.settings.angle + ((emitter.settings.angleVariation > 0) ? (randomFloat(0, 2) - 1) * emitter.settings.angleVariation : 0);
|
|
71
|
+
let speed = emitter.settings.speed + ((emitter.settings.speedVariation > 0) ? (randomFloat(0, 2) - 1) * emitter.settings.speedVariation : 0);
|
|
72
72
|
|
|
73
73
|
// Set the start particle Velocity
|
|
74
74
|
this.vel.set(speed * Math.cos(angle), -speed * Math.sin(angle));
|
|
@@ -118,7 +118,7 @@ import Renderable from '../renderable/renderable.js';
|
|
|
118
118
|
*/
|
|
119
119
|
update(dt) {
|
|
120
120
|
// move things forward independent of the current frame rate
|
|
121
|
-
|
|
121
|
+
let skew = dt * this._deltaInv;
|
|
122
122
|
|
|
123
123
|
// Decrease particle life
|
|
124
124
|
this.life = this.life > dt ? this.life - dt : 0;
|
|
@@ -129,10 +129,10 @@ import Renderable from '../renderable/renderable.js';
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// Calculate the particle Age Ratio
|
|
132
|
-
|
|
132
|
+
let ageRatio = this.life / this.startLife;
|
|
133
133
|
|
|
134
134
|
// Resize the particle as particle Age Ratio
|
|
135
|
-
|
|
135
|
+
let scale = this.startScale;
|
|
136
136
|
if (this.startScale > this.endScale) {
|
|
137
137
|
scale *= ageRatio;
|
|
138
138
|
scale = (scale < this.endScale) ? this.endScale : scale;
|
|
@@ -150,7 +150,7 @@ import Renderable from '../renderable/renderable.js';
|
|
|
150
150
|
this.vel.y += this.gravity * skew;
|
|
151
151
|
|
|
152
152
|
// If necessary update the rotation of particle in accordance the particle trajectory
|
|
153
|
-
|
|
153
|
+
let angle = this.followTrajectory ? Math.atan2(this.vel.y, this.vel.x) : this.angle;
|
|
154
154
|
|
|
155
155
|
this.pos.x += this.vel.x * skew;
|
|
156
156
|
this.pos.y += this.vel.y * skew;
|
|
@@ -172,7 +172,7 @@ import Renderable from '../renderable/renderable.js';
|
|
|
172
172
|
* @ignore
|
|
173
173
|
*/
|
|
174
174
|
draw(renderer) {
|
|
175
|
-
|
|
175
|
+
let w = this.width, h = this.height;
|
|
176
176
|
renderer.drawImage(
|
|
177
177
|
this.image,
|
|
178
178
|
0, 0,
|
|
@@ -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
|
|
@@ -85,7 +85,7 @@ const ParticleEmitterSettings = {
|
|
|
85
85
|
angle : Math.PI / 2,
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* letiation in the start angle for particle launch in Radians.
|
|
89
89
|
* @public
|
|
90
90
|
* @type {number}
|
|
91
91
|
* @name angleVariation
|
|
@@ -125,7 +125,7 @@ const ParticleEmitterSettings = {
|
|
|
125
125
|
speed : 2,
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
128
|
+
* letiation in the start speed of particles
|
|
129
129
|
* @public
|
|
130
130
|
* @type {number}
|
|
131
131
|
* @name speedVariation
|
|
@@ -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
|
|
@@ -219,7 +219,7 @@ import Point from '../geometries/point.js';
|
|
|
219
219
|
// parses the given shapes array and add them
|
|
220
220
|
if (typeof shapes !== "undefined") {
|
|
221
221
|
if (Array.isArray(shapes)) {
|
|
222
|
-
for (
|
|
222
|
+
for (let s = 0; s < shapes.length; s++) {
|
|
223
223
|
this.addShape(shapes[s]);
|
|
224
224
|
}
|
|
225
225
|
} else {
|
|
@@ -253,7 +253,7 @@ import Point from '../geometries/point.js';
|
|
|
253
253
|
*/
|
|
254
254
|
addShape(shape) {
|
|
255
255
|
if (shape instanceof Rect || shape instanceof Bounds) {
|
|
256
|
-
|
|
256
|
+
let poly = shape.toPolygon();
|
|
257
257
|
this.shapes.push(poly);
|
|
258
258
|
// update the body bounds
|
|
259
259
|
this.bounds.add(poly.points);
|
|
@@ -304,7 +304,7 @@ import Point from '../geometries/point.js';
|
|
|
304
304
|
* @param {boolean} [clear=true] - either to reset the body definition before adding the new vertices
|
|
305
305
|
*/
|
|
306
306
|
setVertices(vertices, index = 0, clear = true) {
|
|
307
|
-
|
|
307
|
+
let polygon = this.getShape(index);
|
|
308
308
|
if (polygon instanceof Polygon) {
|
|
309
309
|
polygon.setShape(0, 0, vertices);
|
|
310
310
|
} else {
|
|
@@ -343,7 +343,7 @@ import Point from '../geometries/point.js';
|
|
|
343
343
|
* this.body.fromJSON(me.loader.getJSON("shapesdef"), "banana");
|
|
344
344
|
*/
|
|
345
345
|
fromJSON(json, id) {
|
|
346
|
-
|
|
346
|
+
let data = json;
|
|
347
347
|
|
|
348
348
|
if (typeof id !== "undefined" ) {
|
|
349
349
|
data = json[id];
|
|
@@ -356,7 +356,7 @@ import Point from '../geometries/point.js';
|
|
|
356
356
|
|
|
357
357
|
if (data.length) {
|
|
358
358
|
// go through all shapes and add them to the body
|
|
359
|
-
for (
|
|
359
|
+
for (let i = 0; i < data.length; i++) {
|
|
360
360
|
this.addVertices(data[i].shape, i);
|
|
361
361
|
}
|
|
362
362
|
// apply density, friction and bounce properties from the first shape
|
|
@@ -398,7 +398,7 @@ import Point from '../geometries/point.js';
|
|
|
398
398
|
// remove the shape from shape list
|
|
399
399
|
remove(this.shapes, shape);
|
|
400
400
|
// add everything left back
|
|
401
|
-
for (
|
|
401
|
+
for (let s = 0; s < this.shapes.length; s++) {
|
|
402
402
|
this.addShape(this.shapes[s]);
|
|
403
403
|
}
|
|
404
404
|
// return the length of the shape list
|
|
@@ -455,7 +455,7 @@ import Point from '../geometries/point.js';
|
|
|
455
455
|
*/
|
|
456
456
|
respondToCollision(response) {
|
|
457
457
|
// the overlap vector
|
|
458
|
-
|
|
458
|
+
let overlap = response.overlapV;
|
|
459
459
|
|
|
460
460
|
// FIXME: Respond proportionally to object mass
|
|
461
461
|
|
|
@@ -477,7 +477,7 @@ import Point from '../geometries/point.js';
|
|
|
477
477
|
|
|
478
478
|
if (!this.ignoreGravity) {
|
|
479
479
|
// cancel the falling an jumping flags if necessary
|
|
480
|
-
|
|
480
|
+
let dir = this.falling === true ? 1 : this.jumping === true ? -1 : 0;
|
|
481
481
|
this.falling = overlap.y >= dir;
|
|
482
482
|
this.jumping = overlap.y <= -dir;
|
|
483
483
|
}
|
|
@@ -502,10 +502,10 @@ import Point from '../geometries/point.js';
|
|
|
502
502
|
* mySprite.body.forEach((shape, index, array) => { ... }, thisArg);
|
|
503
503
|
*/
|
|
504
504
|
forEach(callback, thisArg) {
|
|
505
|
-
|
|
506
|
-
|
|
505
|
+
let context = this, i = 0;
|
|
506
|
+
let shapes = this.shapes;
|
|
507
507
|
|
|
508
|
-
|
|
508
|
+
let len = shapes.length;
|
|
509
509
|
|
|
510
510
|
if (typeof callback !== "function") {
|
|
511
511
|
throw new Error(callback + " is not a function");
|
|
@@ -534,7 +534,7 @@ import Point from '../geometries/point.js';
|
|
|
534
534
|
* @returns {boolean} true if contains
|
|
535
535
|
*/
|
|
536
536
|
contains() {
|
|
537
|
-
|
|
537
|
+
let _x, _y;
|
|
538
538
|
|
|
539
539
|
if (arguments.length === 2) {
|
|
540
540
|
// x, y
|
|
@@ -548,7 +548,7 @@ import Point from '../geometries/point.js';
|
|
|
548
548
|
|
|
549
549
|
if (this.getBounds().contains(_x, _y)) {
|
|
550
550
|
// cannot use forEach here as cannot break out with a return
|
|
551
|
-
for (
|
|
551
|
+
for (let i = this.shapes.length, shape; i--, (shape = this.shapes[i]);) {
|
|
552
552
|
if (shape.contains(_x, _y)) {
|
|
553
553
|
return true;
|
|
554
554
|
}
|
|
@@ -622,7 +622,7 @@ import Point from '../geometries/point.js';
|
|
|
622
622
|
update(dt) { // eslint-disable-line no-unused-vars
|
|
623
623
|
// apply timer.tick to delta time for linear interpolation (when enabled)
|
|
624
624
|
// #761 add delta time in body update
|
|
625
|
-
|
|
625
|
+
let deltaTime = /* dt * */ timer.tick;
|
|
626
626
|
|
|
627
627
|
// apply force if defined
|
|
628
628
|
if (this.force.x !== 0) {
|
|
@@ -634,7 +634,7 @@ import Point from '../geometries/point.js';
|
|
|
634
634
|
|
|
635
635
|
// apply friction if defined
|
|
636
636
|
if (this.friction.x > 0) {
|
|
637
|
-
|
|
637
|
+
let fx = this.friction.x * deltaTime,
|
|
638
638
|
nx = this.vel.x + fx,
|
|
639
639
|
x = this.vel.x - fx;
|
|
640
640
|
|
|
@@ -644,7 +644,7 @@ import Point from '../geometries/point.js';
|
|
|
644
644
|
);
|
|
645
645
|
}
|
|
646
646
|
if (this.friction.y > 0) {
|
|
647
|
-
|
|
647
|
+
let fy = this.friction.y * deltaTime,
|
|
648
648
|
ny = this.vel.y + fy,
|
|
649
649
|
y = this.vel.y - fy;
|
|
650
650
|
|
|
@@ -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
|
|
@@ -69,7 +69,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
set x(value) {
|
|
72
|
-
|
|
72
|
+
let deltaX = this.max.x - this.min.x;
|
|
73
73
|
this.min.x = value;
|
|
74
74
|
this.max.x = value + deltaX;
|
|
75
75
|
}
|
|
@@ -83,7 +83,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
set y(value) {
|
|
86
|
-
|
|
86
|
+
let deltaY = this.max.y - this.min.y;
|
|
87
87
|
|
|
88
88
|
this.min.y = value;
|
|
89
89
|
this.max.y = value + deltaY;
|
|
@@ -196,8 +196,8 @@ import Vector2d from '../math/vector2.js';
|
|
|
196
196
|
if (clear === true) {
|
|
197
197
|
this.clear();
|
|
198
198
|
}
|
|
199
|
-
for (
|
|
200
|
-
|
|
199
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
200
|
+
let vertex = vertices[i];
|
|
201
201
|
if (vertex.x > this.max.x) this.max.x = vertex.x;
|
|
202
202
|
if (vertex.x < this.min.x) this.min.x = vertex.x;
|
|
203
203
|
if (vertex.y > this.max.y) this.max.y = vertex.y;
|
|
@@ -249,7 +249,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
249
249
|
* @param {Matrix2d} [m] - an optional transform to apply to the given frame coordinates
|
|
250
250
|
*/
|
|
251
251
|
addFrame(x0, y0, x1, y1, m) {
|
|
252
|
-
|
|
252
|
+
let v = pool.pull("Point");
|
|
253
253
|
|
|
254
254
|
this.addPoint(v.set(x0, y0), m);
|
|
255
255
|
this.addPoint(v.set(x1, y0), m);
|
|
@@ -274,8 +274,8 @@ import Vector2d from '../math/vector2.js';
|
|
|
274
274
|
* @returns {boolean} True if the bounds contain the point, otherwise false
|
|
275
275
|
*/
|
|
276
276
|
contains() {
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
let arg0 = arguments[0];
|
|
278
|
+
let _x1, _x2, _y1, _y2;
|
|
279
279
|
if (arguments.length === 2) {
|
|
280
280
|
// x, y
|
|
281
281
|
_x1 = _x2 = arg0;
|
|
@@ -329,7 +329,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
329
329
|
* @param {number} y
|
|
330
330
|
*/
|
|
331
331
|
translate() {
|
|
332
|
-
|
|
332
|
+
let _x, _y;
|
|
333
333
|
if (arguments.length === 2) {
|
|
334
334
|
// x, y
|
|
335
335
|
_x = arguments[0];
|
|
@@ -358,7 +358,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
358
358
|
* @param {number} y
|
|
359
359
|
*/
|
|
360
360
|
shift() {
|
|
361
|
-
|
|
361
|
+
let _x, _y;
|
|
362
362
|
|
|
363
363
|
if (arguments.length === 2) {
|
|
364
364
|
// x, y
|
|
@@ -370,7 +370,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
370
370
|
_y = arguments[0].y;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
let deltaX = this.max.x - this.min.x,
|
|
374
374
|
deltaY = this.max.y - this.min.y;
|
|
375
375
|
|
|
376
376
|
this.min.x = _x;
|
|
@@ -384,7 +384,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
384
384
|
* @returns {Bounds}
|
|
385
385
|
*/
|
|
386
386
|
clone() {
|
|
387
|
-
|
|
387
|
+
let bounds = new Bounds();
|
|
388
388
|
bounds.addBounds(this);
|
|
389
389
|
return bounds;
|
|
390
390
|
}
|
|
@@ -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 { game } from '../index.js';
|
|
|
13
13
|
* @namespace collision
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
let collision = {
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The maximum number of children that a quadtree node can contain before it is split into sub-nodes.
|
|
@@ -108,7 +108,7 @@ var collision = {
|
|
|
108
108
|
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
109
109
|
* @example
|
|
110
110
|
* // define a line accross the viewport
|
|
111
|
-
*
|
|
111
|
+
* let ray = new me.Line(
|
|
112
112
|
* // absolute position of the line
|
|
113
113
|
* 0, 0, [
|
|
114
114
|
* // starting point relative to the initial position
|
|
@@ -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
|
|
@@ -52,7 +52,7 @@ class Detector {
|
|
|
52
52
|
* @returns {boolean} true if they should collide, false otherwise
|
|
53
53
|
*/
|
|
54
54
|
shouldCollide(a, b) {
|
|
55
|
-
|
|
55
|
+
let bodyA = a.body,
|
|
56
56
|
bodyB = b.body;
|
|
57
57
|
return (
|
|
58
58
|
(typeof bodyA === "object" && typeof bodyB === "object") &&
|
|
@@ -73,9 +73,9 @@ class Detector {
|
|
|
73
73
|
*/
|
|
74
74
|
collides(bodyA, bodyB, response = this.response) {
|
|
75
75
|
// for each shape in body A
|
|
76
|
-
for (
|
|
76
|
+
for (let indexA = bodyA.shapes.length, shapeA; indexA--, (shapeA = bodyA.shapes[indexA]);) {
|
|
77
77
|
// for each shape in body B
|
|
78
|
-
for (
|
|
78
|
+
for (let indexB = bodyB.shapes.length, shapeB; indexB--, (shapeB = bodyB.shapes[indexB]);) {
|
|
79
79
|
// full SAT collision check
|
|
80
80
|
if (sat["test" + shapeA.shapeType + shapeB.shapeType].call(
|
|
81
81
|
this,
|
|
@@ -105,9 +105,9 @@ class Detector {
|
|
|
105
105
|
* @returns {boolean} in case of collision, false otherwise
|
|
106
106
|
*/
|
|
107
107
|
collisions(objA) {
|
|
108
|
-
|
|
108
|
+
let collisionCounter = 0;
|
|
109
109
|
// retreive a list of potential colliding objects from the game world
|
|
110
|
-
|
|
110
|
+
let candidates = this.world.broadphase.retrieve(objA);
|
|
111
111
|
|
|
112
112
|
boundsA.addBounds(objA.getBounds(), true);
|
|
113
113
|
boundsA.addBounds(objA.body.getBounds());
|
|
@@ -149,7 +149,7 @@ class Detector {
|
|
|
149
149
|
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
150
150
|
* @example
|
|
151
151
|
* // define a line accross the viewport
|
|
152
|
-
*
|
|
152
|
+
* let ray = new me.Line(
|
|
153
153
|
* // absolute position of the line
|
|
154
154
|
* 0, 0, [
|
|
155
155
|
* // starting point relative to the initial position
|
|
@@ -166,28 +166,28 @@ class Detector {
|
|
|
166
166
|
* }
|
|
167
167
|
*/
|
|
168
168
|
rayCast(line, result = []) {
|
|
169
|
-
|
|
169
|
+
let collisionCounter = 0;
|
|
170
170
|
|
|
171
171
|
// retrieve a list of potential colliding objects from the game world
|
|
172
|
-
|
|
172
|
+
let candidates = this.world.broadphase.retrieve(line);
|
|
173
173
|
|
|
174
|
-
for (
|
|
174
|
+
for (let i = candidates.length, objB; i--, (objB = candidates[i]);) {
|
|
175
175
|
|
|
176
176
|
// fast AABB check if both bounding boxes are overlaping
|
|
177
177
|
if (objB.body && line.getBounds().overlaps(objB.getBounds())) {
|
|
178
178
|
|
|
179
179
|
// go trough all defined shapes in B (if any)
|
|
180
|
-
|
|
180
|
+
let bLen = objB.body.shapes.length;
|
|
181
181
|
if ( objB.body.shapes.length === 0) {
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
let shapeA = line;
|
|
186
186
|
|
|
187
187
|
// go through all defined shapes in B
|
|
188
|
-
|
|
188
|
+
let indexB = 0;
|
|
189
189
|
do {
|
|
190
|
-
|
|
190
|
+
let shapeB = objB.body.getShape(indexB);
|
|
191
191
|
|
|
192
192
|
// full SAT collision check
|
|
193
193
|
if (sat["test" + shapeA.shapeType + shapeB.shapeType]
|