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
package/src/geometries/path2d.js
CHANGED
|
@@ -42,7 +42,7 @@ import earcut from "earcut";
|
|
|
42
42
|
* If the shape has already been closed or has only one point, this function does nothing.
|
|
43
43
|
*/
|
|
44
44
|
closePath() {
|
|
45
|
-
|
|
45
|
+
let points = this.points;
|
|
46
46
|
if (points.length > 1 && !points[points.length-1].equals(points[0])) {
|
|
47
47
|
points.push(pool.pull("Point", points[0].x, points[0].y));
|
|
48
48
|
}
|
|
@@ -53,10 +53,10 @@ import earcut from "earcut";
|
|
|
53
53
|
* @returns {Point[]}
|
|
54
54
|
*/
|
|
55
55
|
triangulatePath() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
let i = 0;
|
|
57
|
+
let points = this.points;
|
|
58
|
+
let vertices = this.vertices;
|
|
59
|
+
let indices = earcut(points.flatMap(p => [p.x, p.y]));
|
|
60
60
|
|
|
61
61
|
// pre-allocate vertices if necessary
|
|
62
62
|
while (vertices.length < indices.length) {
|
|
@@ -65,7 +65,7 @@ import earcut from "earcut";
|
|
|
65
65
|
|
|
66
66
|
// calculate all vertices
|
|
67
67
|
for (i = 0; i < indices.length; i++ ) {
|
|
68
|
-
|
|
68
|
+
let point = points[indices[i]];
|
|
69
69
|
vertices[i].set(point.x, point.y);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -107,11 +107,11 @@ import earcut from "earcut";
|
|
|
107
107
|
* @param {boolean} [anticlockwise=false] - an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
|
|
108
108
|
*/
|
|
109
109
|
arc(x, y, radius, startAngle, endAngle, anticlockwise = false) {
|
|
110
|
-
|
|
110
|
+
let points = this.points;
|
|
111
111
|
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
112
112
|
//bring angles all in [0, 2*PI] range
|
|
113
113
|
if (startAngle === endAngle) return;
|
|
114
|
-
|
|
114
|
+
const fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
115
115
|
|
|
116
116
|
startAngle = startAngle % (TAU);
|
|
117
117
|
endAngle = endAngle % (TAU);
|
|
@@ -123,8 +123,8 @@ import earcut from "earcut";
|
|
|
123
123
|
endAngle+= TAU;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
let diff = endAngle - startAngle;
|
|
127
|
+
let direction = 1;
|
|
128
128
|
if (anticlockwise) {
|
|
129
129
|
direction = -1;
|
|
130
130
|
diff = TAU - diff;
|
|
@@ -132,12 +132,12 @@ import earcut from "earcut";
|
|
|
132
132
|
|
|
133
133
|
if (fullCircle) diff = TAU;
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const length = diff * radius;
|
|
136
|
+
const nr_of_interpolation_points = length / this.arcResolution;
|
|
137
|
+
const dangle = diff / nr_of_interpolation_points;
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
for (
|
|
139
|
+
let angle = startAngle;
|
|
140
|
+
for (let j = 0; j < nr_of_interpolation_points; j++) {
|
|
141
141
|
points.push(pool.pull("Point", x + radius * Math.cos(angle), y + radius * Math.sin(angle)));
|
|
142
142
|
angle += direction * dangle;
|
|
143
143
|
}
|
|
@@ -153,40 +153,40 @@ import earcut from "earcut";
|
|
|
153
153
|
* @param {number} radius - the arc's radius. Must be positive.
|
|
154
154
|
*/
|
|
155
155
|
arcTo(x1, y1, x2, y2, radius) {
|
|
156
|
-
|
|
156
|
+
let points = this.points;
|
|
157
157
|
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
158
|
-
|
|
158
|
+
let x0 = points[points.length-1].x, y0 = points[points.length-1].y;
|
|
159
159
|
|
|
160
160
|
//a = -incoming vector, b = outgoing vector to x1, y1
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
let a0 = x0 - x1, a1 = y0 - y1;
|
|
162
|
+
let b0 = x2 - x1, b1 = y2 - y1;
|
|
163
163
|
|
|
164
164
|
//normalize
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
let l_a = Math.sqrt(Math.pow(a0, 2) + Math.pow(a1, 2));
|
|
166
|
+
let l_b = Math.sqrt(Math.pow(b0, 2) + Math.pow(b1, 2));
|
|
167
|
+
a0 /= l_a; a1 /= l_a; b0 /= l_b; b1 /= l_b;
|
|
168
|
+
let angle = Math.atan2(a1, a0) - Math.atan2(b1, b0);
|
|
169
169
|
|
|
170
170
|
//work out tangent points using tan(θ) = opposite / adjacent; angle/2 because hypotenuse is the bisection of a,b
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
let tan_angle_div2 = Math.tan(angle/2);
|
|
172
|
+
let adj_l = (radius/tan_angle_div2);
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
let tangent1_pointx = x1 + a0 * adj_l, tangent1_pointy = y1 + a1 * adj_l;
|
|
175
|
+
let tangent2_pointx = x1 + b0 * adj_l, tangent2_pointy = y1 + b1 * adj_l;
|
|
176
176
|
|
|
177
|
-
points.push(pool.pull("Point",
|
|
177
|
+
points.push(pool.pull("Point", tangent1_pointx, tangent1_pointy));
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
let bisec0 = (a0 + b0) / 2.0, bisec1 = (a1 + b1) / 2.0;
|
|
180
|
+
let bisec_l = Math.sqrt(Math.pow(bisec0, 2) + Math.pow(bisec1, 2));
|
|
181
|
+
bisec0 /= bisec_l; bisec1 /= bisec_l;
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
let hyp_l = Math.sqrt(Math.pow(radius, 2) + Math.pow(adj_l, 2));
|
|
184
|
+
let centerx = x1 + hyp_l * bisec0, centery = y1 + hyp_l * bisec1;
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
let startAngle = Math.atan2(tangent1_pointy - centery, tangent1_pointx - centerx);
|
|
187
|
+
let endAngle = Math.atan2(tangent2_pointy - centery, tangent2_pointx - centerx);
|
|
188
188
|
|
|
189
|
-
this.arc(
|
|
189
|
+
this.arc(centerx, centery, radius, startAngle, endAngle);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
@@ -202,10 +202,10 @@ import earcut from "earcut";
|
|
|
202
202
|
* @param {boolean} [anticlockwise=false] - an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
|
|
203
203
|
*/
|
|
204
204
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
205
|
-
|
|
205
|
+
let points = this.points;
|
|
206
206
|
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
207
207
|
if (startAngle === endAngle) return;
|
|
208
|
-
|
|
208
|
+
let fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
209
209
|
|
|
210
210
|
//bring angles all in [0, 2*PI] range
|
|
211
211
|
startAngle = startAngle % (TAU);
|
|
@@ -217,9 +217,9 @@ import earcut from "earcut";
|
|
|
217
217
|
endAngle += TAU;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
let diff = endAngle - startAngle;
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
let direction = 1;
|
|
223
223
|
if (anticlockwise) {
|
|
224
224
|
direction = -1;
|
|
225
225
|
diff = TAU - diff;
|
|
@@ -227,18 +227,18 @@ import earcut from "earcut";
|
|
|
227
227
|
|
|
228
228
|
if (fullCircle) diff = TAU;
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
for (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
230
|
+
const length = (diff * radiusX + diff * radiusY) / 2;
|
|
231
|
+
const nr_of_interpolation_points = length / this.arcResolution;
|
|
232
|
+
const dangle = diff / nr_of_interpolation_points;
|
|
233
|
+
|
|
234
|
+
let angle = startAngle;
|
|
235
|
+
const cos_rotation = Math.cos(rotation);
|
|
236
|
+
const sin_rotation = Math.sin(rotation);
|
|
237
|
+
for (let j = 0; j < nr_of_interpolation_points; j++) {
|
|
238
|
+
let _x1 = radiusX * Math.cos(angle);
|
|
239
|
+
let _y1 = radiusY * Math.sin(angle);
|
|
240
|
+
let _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
|
|
241
|
+
let _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
|
|
242
242
|
points.push(pool.pull("Point", _x2, _y2));
|
|
243
243
|
angle += direction * dangle;
|
|
244
244
|
}
|
package/src/geometries/point.js
CHANGED
package/src/geometries/poly.js
CHANGED
|
@@ -119,7 +119,7 @@ import pool from "./../system/pooling.js";
|
|
|
119
119
|
|
|
120
120
|
} else {
|
|
121
121
|
// it's a flat array
|
|
122
|
-
for (
|
|
122
|
+
for (let p = 0; p < vertices.length; p += 2) {
|
|
123
123
|
this.points.push(pool.pull("Vector2d", vertices[p], vertices[p + 1]));
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -141,9 +141,9 @@ import pool from "./../system/pooling.js";
|
|
|
141
141
|
* @returns {Polygon} Reference to this object for method chaining
|
|
142
142
|
*/
|
|
143
143
|
transform(m) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
for (
|
|
144
|
+
let points = this.points;
|
|
145
|
+
let len = points.length;
|
|
146
|
+
for (let i = 0; i < len; i++) {
|
|
147
147
|
m.apply(points[i]);
|
|
148
148
|
}
|
|
149
149
|
this.recalc();
|
|
@@ -181,9 +181,9 @@ import pool from "./../system/pooling.js";
|
|
|
181
181
|
*/
|
|
182
182
|
rotate(angle, v) {
|
|
183
183
|
if (angle !== 0) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
for (
|
|
184
|
+
let points = this.points;
|
|
185
|
+
let len = points.length;
|
|
186
|
+
for (let i = 0; i < len; i++) {
|
|
187
187
|
points[i].rotate(angle, v);
|
|
188
188
|
}
|
|
189
189
|
this.recalc();
|
|
@@ -201,9 +201,9 @@ import pool from "./../system/pooling.js";
|
|
|
201
201
|
* @returns {Polygon} Reference to this object for method chaining
|
|
202
202
|
*/
|
|
203
203
|
scale(x, y = x) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
for (
|
|
204
|
+
let points = this.points;
|
|
205
|
+
let len = points.length;
|
|
206
|
+
for (let i = 0; i < len; i++) {
|
|
207
207
|
points[i].scale(x, y);
|
|
208
208
|
}
|
|
209
209
|
this.recalc();
|
|
@@ -230,14 +230,14 @@ import pool from "./../system/pooling.js";
|
|
|
230
230
|
* @returns {Polygon} Reference to this object for method chaining
|
|
231
231
|
*/
|
|
232
232
|
recalc() {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
let i;
|
|
234
|
+
let edges = this.edges;
|
|
235
|
+
let normals = this.normals;
|
|
236
|
+
let indices = this.indices;
|
|
237
237
|
|
|
238
238
|
// Copy the original points array and apply the offset/angle
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
let points = this.points;
|
|
240
|
+
let len = points.length;
|
|
241
241
|
|
|
242
242
|
if (len < 3) {
|
|
243
243
|
throw new Error("Requires at least 3 points");
|
|
@@ -289,7 +289,7 @@ import pool from "./../system/pooling.js";
|
|
|
289
289
|
// http://paulbourke.net/geometry/polygonmesh/
|
|
290
290
|
// Copyright (c) Paul Bourke (use permitted)
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
let flag = 0,
|
|
293
293
|
vertices = this.points,
|
|
294
294
|
n = vertices.length,
|
|
295
295
|
i,
|
|
@@ -342,7 +342,7 @@ import pool from "./../system/pooling.js";
|
|
|
342
342
|
* @returns {Polygon} Reference to this object for method chaining
|
|
343
343
|
*/
|
|
344
344
|
translate() {
|
|
345
|
-
|
|
345
|
+
let _x, _y;
|
|
346
346
|
|
|
347
347
|
if (arguments.length === 2) {
|
|
348
348
|
// x, y
|
|
@@ -376,7 +376,7 @@ import pool from "./../system/pooling.js";
|
|
|
376
376
|
* @param {number} y
|
|
377
377
|
*/
|
|
378
378
|
shift() {
|
|
379
|
-
|
|
379
|
+
let _x, _y;
|
|
380
380
|
if (arguments.length === 2) {
|
|
381
381
|
// x, y
|
|
382
382
|
_x = arguments[0];
|
|
@@ -413,7 +413,7 @@ import pool from "./../system/pooling.js";
|
|
|
413
413
|
* @returns {boolean} true if contains
|
|
414
414
|
*/
|
|
415
415
|
contains() {
|
|
416
|
-
|
|
416
|
+
let _x, _y;
|
|
417
417
|
|
|
418
418
|
if (arguments.length === 2) {
|
|
419
419
|
// x, y
|
|
@@ -425,14 +425,14 @@ import pool from "./../system/pooling.js";
|
|
|
425
425
|
_y = arguments[0].y;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
let intersects = false;
|
|
429
|
+
let posx = this.pos.x, posy = this.pos.y;
|
|
430
|
+
let points = this.points;
|
|
431
|
+
let len = points.length;
|
|
432
432
|
|
|
433
433
|
//http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
|
434
|
-
for (
|
|
435
|
-
|
|
434
|
+
for (let i = 0, j = len - 1; i < len; j = i++) {
|
|
435
|
+
let iy = points[i].y + posy, ix = points[i].x + posx,
|
|
436
436
|
jy = points[j].y + posy, jx = points[j].x + posx;
|
|
437
437
|
if (((iy > _y) !== (jy > _y)) && (_x < (jx - ix) * (_y - iy) / (jy - iy) + ix)) {
|
|
438
438
|
intersects = !intersects;
|
|
@@ -461,7 +461,7 @@ import pool from "./../system/pooling.js";
|
|
|
461
461
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
462
462
|
*/
|
|
463
463
|
updateBounds() {
|
|
464
|
-
|
|
464
|
+
let bounds = this.getBounds();
|
|
465
465
|
|
|
466
466
|
bounds.update(this.points);
|
|
467
467
|
bounds.translate(this.pos);
|
|
@@ -476,7 +476,7 @@ import pool from "./../system/pooling.js";
|
|
|
476
476
|
* @returns {Polygon} new Polygon
|
|
477
477
|
*/
|
|
478
478
|
clone() {
|
|
479
|
-
|
|
479
|
+
let copy = [];
|
|
480
480
|
this.points.forEach((point) => {
|
|
481
481
|
copy.push(point.clone());
|
|
482
482
|
});
|
|
@@ -40,7 +40,7 @@ import Polygon from "./poly.js";
|
|
|
40
40
|
* @returns {Rect} this rectangle
|
|
41
41
|
*/
|
|
42
42
|
setShape(x, y, w, h) {
|
|
43
|
-
|
|
43
|
+
let points = w; // assume w is an array by default
|
|
44
44
|
|
|
45
45
|
this.pos.set(x, y);
|
|
46
46
|
|
|
@@ -76,7 +76,7 @@ import Polygon from "./poly.js";
|
|
|
76
76
|
* @memberof Rect
|
|
77
77
|
*/
|
|
78
78
|
get right() {
|
|
79
|
-
|
|
79
|
+
let w = this.width;
|
|
80
80
|
return (this.left + w) || w;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -99,7 +99,7 @@ import Polygon from "./poly.js";
|
|
|
99
99
|
* @memberof Rect
|
|
100
100
|
*/
|
|
101
101
|
get bottom() {
|
|
102
|
-
|
|
102
|
+
let h = this.height;
|
|
103
103
|
return (this.top + h) || h;
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -246,8 +246,8 @@ import Polygon from "./poly.js";
|
|
|
246
246
|
* @returns {Rect} the union(ed) rectangle
|
|
247
247
|
*/
|
|
248
248
|
union(rect) {
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
let x1 = Math.min(this.left, rect.left);
|
|
250
|
+
let y1 = Math.min(this.top, rect.top);
|
|
251
251
|
|
|
252
252
|
this.resize(
|
|
253
253
|
Math.max(this.right, rect.right) - x1,
|
|
@@ -302,8 +302,8 @@ import Polygon from "./poly.js";
|
|
|
302
302
|
* @returns {boolean} true if contains
|
|
303
303
|
*/
|
|
304
304
|
contains() {
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
let arg0 = arguments[0];
|
|
306
|
+
let _x1, _x2, _y1, _y2;
|
|
307
307
|
if (arguments.length === 2) {
|
|
308
308
|
// x, y
|
|
309
309
|
_x1 = _x2 = arg0;
|
|
@@ -83,8 +83,8 @@ export default class RoundRect extends Rect {
|
|
|
83
83
|
* @returns {boolean} true if contains
|
|
84
84
|
*/
|
|
85
85
|
contains() {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
let arg0 = arguments[0];
|
|
87
|
+
let _x, _y;
|
|
88
88
|
if (arguments.length === 2) {
|
|
89
89
|
// x, y
|
|
90
90
|
_x = arg0;
|
|
@@ -111,9 +111,9 @@ export default class RoundRect extends Rect {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// check whether point is in one of the rounded corner areas
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
let tx, ty;
|
|
115
|
+
const radiusX = Math.max(0, Math.min(this.radius, this.width / 2));
|
|
116
|
+
const radiusY = Math.max(0, Math.min(this.radius, this.height / 2));
|
|
117
117
|
|
|
118
118
|
if (_x < this.left + radiusX && _y < this.top + radiusY) {
|
|
119
119
|
tx = _x - this.left - radiusX;
|
package/src/index.js
CHANGED
|
@@ -135,6 +135,7 @@ export {
|
|
|
135
135
|
Renderer,
|
|
136
136
|
WebGLRenderer,
|
|
137
137
|
CanvasRenderer,
|
|
138
|
+
CanvasTexture,
|
|
138
139
|
TextureAtlas,
|
|
139
140
|
Renderable,
|
|
140
141
|
Body,
|
|
@@ -188,7 +189,7 @@ export * from "./const.js";
|
|
|
188
189
|
* @default false
|
|
189
190
|
* @readonly
|
|
190
191
|
*/
|
|
191
|
-
export
|
|
192
|
+
export let initialized = false;
|
|
192
193
|
|
|
193
194
|
/**
|
|
194
195
|
* disable melonJS auto-initialization
|
|
@@ -196,7 +197,7 @@ export var initialized = false;
|
|
|
196
197
|
* @default false
|
|
197
198
|
* @see boot
|
|
198
199
|
*/
|
|
199
|
-
export
|
|
200
|
+
export let skipAutoInit = false;
|
|
200
201
|
|
|
201
202
|
/*
|
|
202
203
|
* game is a default instance of a melonJS Application and represents your current game,
|
package/src/input/gamepad.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as event from "./../system/event.js";
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// Analog deadzone
|
|
6
|
-
|
|
6
|
+
let deadzone = 0.1;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Normalize axis values for wired Xbox 360
|
|
@@ -41,10 +41,10 @@ function ouyaNormalizeFn(value, axis, button) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Match vendor and product codes for Firefox
|
|
44
|
-
|
|
44
|
+
const vendorProductRE = /^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i;
|
|
45
45
|
|
|
46
46
|
// Match leading zeros
|
|
47
|
-
|
|
47
|
+
const leadingZeroRE = /^0+/;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Firefox reports different ids for gamepads depending on the platform:
|
|
@@ -55,11 +55,11 @@ var leadingZeroRE = /^0+/;
|
|
|
55
55
|
* @ignore
|
|
56
56
|
*/
|
|
57
57
|
function addMapping(id, mapping) {
|
|
58
|
-
|
|
58
|
+
const expanded_id = id.replace(vendorProductRE, (_, a, b) =>
|
|
59
59
|
"000".slice(a.length - 1) + a + "-" +
|
|
60
60
|
"000".slice(b.length - 1) + b + "-"
|
|
61
61
|
);
|
|
62
|
-
|
|
62
|
+
const sparse_id = id.replace(vendorProductRE, (_, a, b) =>
|
|
63
63
|
a.replace(leadingZeroRE, "") + "-" +
|
|
64
64
|
b.replace(leadingZeroRE, "") + "-"
|
|
65
65
|
);
|
|
@@ -73,12 +73,12 @@ function addMapping(id, mapping) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// binding list
|
|
76
|
-
|
|
76
|
+
let bindings = {};
|
|
77
77
|
|
|
78
78
|
// mapping list
|
|
79
|
-
|
|
79
|
+
let remap = new Map();
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
let updateEventHandler;
|
|
82
82
|
|
|
83
83
|
// Default gamepad mappings
|
|
84
84
|
[
|
|
@@ -134,28 +134,28 @@ var updateEventHandler;
|
|
|
134
134
|
* Update gamepad status
|
|
135
135
|
* @ignore
|
|
136
136
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
let updateGamepads = function () {
|
|
138
|
+
let gamepads = navigator.getGamepads();
|
|
139
139
|
|
|
140
140
|
// Trigger button bindings
|
|
141
141
|
Object.keys(bindings).forEach((index) => {
|
|
142
|
-
|
|
142
|
+
let gamepad = gamepads[index];
|
|
143
143
|
if (!gamepad) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
let mapping = null;
|
|
148
148
|
if (gamepad.mapping !== "standard") {
|
|
149
149
|
mapping = remap.get(gamepad.id);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
let binding = bindings[index];
|
|
153
153
|
|
|
154
154
|
// Iterate all buttons that have active bindings
|
|
155
155
|
Object.keys(binding.buttons).forEach((button) => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
let last = binding.buttons[button];
|
|
157
|
+
let mapped_button = button;
|
|
158
|
+
let mapped_axis = -1;
|
|
159
159
|
|
|
160
160
|
// Remap buttons if necessary
|
|
161
161
|
if (mapping) {
|
|
@@ -168,12 +168,12 @@ var updateGamepads = function () {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// Get mapped button
|
|
171
|
-
|
|
171
|
+
let current = gamepad.buttons[mapped_button] || {};
|
|
172
172
|
|
|
173
173
|
// Remap an axis to an analog button
|
|
174
174
|
if (mapping) {
|
|
175
175
|
if (mapped_axis >= 0) {
|
|
176
|
-
|
|
176
|
+
let value = mapping.normalize_fn(gamepad.axes[mapped_axis], -1, +button);
|
|
177
177
|
|
|
178
178
|
// Create a new object, because GamepadButton is read-only
|
|
179
179
|
current = {
|
|
@@ -200,8 +200,8 @@ var updateGamepads = function () {
|
|
|
200
200
|
|
|
201
201
|
// Iterate all axes that have active bindings
|
|
202
202
|
Object.keys(binding.axes).forEach((axis) => {
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
let last = binding.axes[axis];
|
|
204
|
+
let mapped_axis = axis;
|
|
205
205
|
|
|
206
206
|
// Remap buttons if necessary
|
|
207
207
|
if (mapping) {
|
|
@@ -213,7 +213,7 @@ var updateGamepads = function () {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
// retrieve the current value and normalize if necessary
|
|
216
|
-
|
|
216
|
+
let value = gamepad.axes[mapped_axis];
|
|
217
217
|
if (typeof(value) === "undefined") {
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
@@ -221,11 +221,11 @@ var updateGamepads = function () {
|
|
|
221
221
|
value = mapping.normalize_fn(value, +axis, -1);
|
|
222
222
|
}
|
|
223
223
|
// normalize value into a [-1, 1] range value (treat 0 as positive)
|
|
224
|
-
|
|
224
|
+
let range = Math.sign(value) || 1;
|
|
225
225
|
if (last[range].keyCode === 0) {
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
let pressed = (Math.abs(value) >= (deadzone + Math.abs(last[range].threshold)));
|
|
229
229
|
|
|
230
230
|
event.emit(event.GAMEPAD_UPDATE, index, "axes", +axis, value);
|
|
231
231
|
|
|
@@ -276,7 +276,7 @@ if (globalThis.navigator && typeof globalThis.navigator.getGamepads === "functio
|
|
|
276
276
|
* @namespace GAMEPAD
|
|
277
277
|
* @memberof input
|
|
278
278
|
*/
|
|
279
|
-
export
|
|
279
|
+
export let GAMEPAD = {
|
|
280
280
|
/**
|
|
281
281
|
* Standard gamepad mapping information for axes<br>
|
|
282
282
|
* <ul>
|
|
@@ -384,13 +384,13 @@ export function bindGamepad(index, button, keyCode) {
|
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
|
|
387
|
+
let mapping = {
|
|
388
388
|
"keyCode" : keyCode,
|
|
389
389
|
"value" : 0,
|
|
390
390
|
"pressed" : false,
|
|
391
391
|
"threshold" : button.threshold // can be undefined
|
|
392
392
|
};
|
|
393
|
-
|
|
393
|
+
let binding = bindings[index][button.type];
|
|
394
394
|
|
|
395
395
|
// Map the gamepad button or axis to the keycode
|
|
396
396
|
if (button.type === "buttons") {
|
|
@@ -398,12 +398,12 @@ export function bindGamepad(index, button, keyCode) {
|
|
|
398
398
|
binding[button.code] = mapping;
|
|
399
399
|
} else if (button.type === "axes") {
|
|
400
400
|
// normalize threshold into a value that can represent both side of the axis
|
|
401
|
-
|
|
401
|
+
let range = (Math.sign(button.threshold) || 1);
|
|
402
402
|
// axes are defined using two objects; one for negative and one for positive
|
|
403
403
|
if (!binding[button.code]) {
|
|
404
404
|
binding[button.code] = {};
|
|
405
405
|
}
|
|
406
|
-
|
|
406
|
+
let axes = binding[button.code];
|
|
407
407
|
axes[range] = mapping;
|
|
408
408
|
|
|
409
409
|
// Ensure the opposite axis exists
|
|
@@ -484,4 +484,4 @@ export function setGamepadDeadzone(value) {
|
|
|
484
484
|
* }
|
|
485
485
|
* });
|
|
486
486
|
*/
|
|
487
|
-
export
|
|
487
|
+
export let setGamepadMapping = addMapping;
|