melonjs 14.4.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +13 -57
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/application/header.js +1 -1
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +5 -7
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +43 -9
- package/dist/melonjs.mjs/geometries/ellipse.js +2 -3
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +20 -44
- package/dist/melonjs.mjs/geometries/point.js +1 -6
- package/dist/melonjs.mjs/geometries/poly.js +2 -5
- package/dist/melonjs.mjs/geometries/rectangle.js +13 -9
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +10 -6
- package/dist/melonjs.mjs/input/gamepad.js +10 -16
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +1 -1
- package/dist/melonjs.mjs/input/pointer.js +1 -1
- package/dist/melonjs.mjs/input/pointerevent.js +3 -17
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- package/dist/melonjs.mjs/level/level.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -8
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +8 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +5 -5
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +24 -0
- package/dist/melonjs.mjs/loader/loader.js +331 -716
- package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +281 -0
- package/dist/melonjs.mjs/loader/settings.js +91 -0
- package/dist/melonjs.mjs/math/color.js +9 -8
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +7 -9
- package/dist/melonjs.mjs/math/matrix3.js +18 -21
- package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
- package/dist/melonjs.mjs/math/observable_vector3.js +3 -4
- package/dist/melonjs.mjs/math/vector2.js +3 -3
- package/dist/melonjs.mjs/math/vector3.js +3 -4
- 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 +1 -1
- 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 +3 -3
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +18 -14
- package/dist/melonjs.mjs/physics/bounds.js +18 -70
- package/dist/melonjs.mjs/physics/collision.js +1 -1
- package/dist/melonjs.mjs/physics/detector.js +1 -1
- package/dist/melonjs.mjs/physics/quadtree.js +1 -1
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +1 -1
- package/dist/melonjs.mjs/physics/world.js +1 -1
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +25 -19
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -1
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +148 -105
- package/dist/melonjs.mjs/renderable/sprite.js +33 -54
- package/dist/melonjs.mjs/renderable/trigger.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -3
- package/dist/melonjs.mjs/state/stage.js +1 -1
- package/dist/melonjs.mjs/state/state.js +2 -2
- 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 +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +8 -18
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +66 -8
- package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +56 -86
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +4 -6
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +1 -1
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +1 -1
- package/dist/melonjs.mjs/utils/string.js +2 -2
- package/dist/melonjs.mjs/utils/utils.js +2 -4
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +7 -11
- package/dist/melonjs.mjs/video/renderer.js +2 -13
- package/dist/melonjs.mjs/video/texture/atlas.js +12 -17
- package/dist/melonjs.mjs/video/texture/cache.js +3 -3
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
- 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 +21 -17
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +77 -0
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +249 -0
- package/dist/melonjs.mjs/video/webgl/{webgl_compositor.js → compositors/webgl_compositor.js} +20 -205
- package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +139 -149
- package/dist/melonjs.module.js +26320 -26376
- package/dist/types/entity/entity.d.ts +3 -3
- package/dist/types/geometries/path2d.d.ts +5 -31
- package/dist/types/geometries/point.d.ts +2 -7
- package/dist/types/geometries/poly.d.ts +0 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/loader/cache.d.ts +7 -0
- package/dist/types/loader/loader.d.ts +166 -181
- package/dist/types/loader/parser.d.ts +41 -0
- package/dist/types/loader/settings.d.ts +57 -0
- package/dist/types/particles/emitter.d.ts +4 -4
- package/dist/types/physics/bounds.d.ts +29 -84
- package/dist/types/renderable/container.d.ts +0 -11
- package/dist/types/renderable/renderable.d.ts +43 -31
- package/dist/types/renderable/sprite.d.ts +3 -3
- package/dist/types/renderable/ui/uitextbutton.d.ts +0 -1
- package/dist/types/state/state.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +2 -2
- package/dist/types/text/text.d.ts +6 -20
- package/dist/types/text/textstyle.d.ts +1 -1
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -5
- package/dist/types/video/renderer.d.ts +1 -5
- package/dist/types/video/webgl/buffer/vertex.d.ts +3 -3
- package/dist/types/video/webgl/compositors/compositor.d.ts +107 -0
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +22 -0
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +72 -0
- package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
- package/dist/types/video/webgl/webgl_renderer.d.ts +34 -28
- package/package.json +18 -18
- package/src/audio/audio.js +4 -6
- package/src/entity/entity.js +42 -8
- package/src/geometries/ellipse.js +1 -2
- package/src/geometries/path2d.js +19 -43
- package/src/geometries/point.js +0 -5
- package/src/geometries/poly.js +1 -4
- package/src/geometries/rectangle.js +12 -8
- package/src/index.js +7 -3
- package/src/input/gamepad.js +9 -15
- package/src/input/pointerevent.js +1 -15
- package/src/level/level.js +2 -2
- package/src/level/tiled/TMXLayer.js +0 -7
- package/src/level/tiled/TMXTileMap.js +7 -3
- package/src/level/tiled/TMXTileset.js +4 -4
- package/src/loader/cache.js +16 -0
- package/src/loader/loader.js +339 -711
- package/src/loader/loadingscreen.js +3 -3
- package/src/loader/parser.js +279 -0
- package/src/loader/settings.js +85 -0
- package/src/math/color.js +8 -7
- package/src/math/matrix2.js +6 -8
- package/src/math/matrix3.js +17 -20
- package/src/math/observable_vector2.js +2 -2
- package/src/math/observable_vector3.js +2 -3
- package/src/math/vector2.js +2 -2
- package/src/math/vector3.js +2 -3
- package/src/particles/emitter.js +2 -2
- package/src/physics/body.js +17 -13
- package/src/physics/bounds.js +17 -69
- package/src/polyfill/index.js +0 -2
- package/src/renderable/container.js +24 -18
- package/src/renderable/imagelayer.js +6 -0
- package/src/renderable/renderable.js +147 -104
- package/src/renderable/sprite.js +32 -53
- package/src/renderable/ui/uitextbutton.js +0 -2
- package/src/state/state.js +1 -1
- package/src/system/device.js +1 -1
- package/src/system/pooling.js +7 -17
- package/src/text/bitmaptext.js +65 -7
- package/src/text/text.js +55 -85
- package/src/text/textstyle.js +3 -5
- package/src/utils/string.js +1 -1
- package/src/utils/utils.js +1 -3
- package/src/video/canvas/canvas_renderer.js +5 -9
- package/src/video/renderer.js +0 -11
- package/src/video/texture/atlas.js +11 -16
- package/src/video/texture/cache.js +2 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +20 -16
- package/src/video/webgl/compositors/compositor.js +226 -0
- package/src/video/webgl/compositors/primitive_compositor.js +68 -0
- package/src/video/webgl/compositors/quad_compositor.js +240 -0
- package/src/video/webgl/shaders/primitive.vert +2 -5
- package/src/video/webgl/shaders/quad.vert +3 -1
- package/src/video/webgl/webgl_renderer.js +137 -147
- package/dist/melonjs.mjs/_virtual/make-built-in.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-define-property.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +0 -10
- package/dist/melonjs.mjs/_virtual/shared.js +0 -10
- package/dist/melonjs.mjs/game.js +0 -29
- package/dist/melonjs.mjs/polyfill/console.js +0 -18
- package/dist/melonjs.mjs/polyfill/performance.js +0 -27
- package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +0 -46
- package/dist/melonjs.mjs/polyfill/roundrect.js +0 -242
- package/dist/melonjs.mjs/renderable/re_container.js +0 -1016
- package/dist/melonjs.mjs/video/utils/resize.js +0 -116
- package/src/polyfill/performance.js +0 -20
- package/src/polyfill/requestAnimationFrame.js +0 -39
- package/src/video/webgl/webgl_compositor.js +0 -486
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* @ignore
|
|
6
6
|
*/
|
|
7
7
|
export default class VertexArrayBuffer {
|
|
8
|
-
constructor(vertex_size: any,
|
|
8
|
+
constructor(vertex_size: any, vertex_per_obj: any);
|
|
9
9
|
vertexSize: any;
|
|
10
|
-
|
|
10
|
+
objSize: any;
|
|
11
11
|
maxVertex: number;
|
|
12
12
|
vertexCount: number;
|
|
13
13
|
buffer: ArrayBuffer;
|
|
@@ -27,7 +27,7 @@ export default class VertexArrayBuffer {
|
|
|
27
27
|
* resize the vertex buffer, retaining its original contents
|
|
28
28
|
* @ignore
|
|
29
29
|
*/
|
|
30
|
-
resize(): VertexArrayBuffer;
|
|
30
|
+
resize(vertexCount: any): VertexArrayBuffer;
|
|
31
31
|
/**
|
|
32
32
|
* push a new vertex to the buffer
|
|
33
33
|
* @ignore
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* A base Compositor object.
|
|
4
|
+
*/
|
|
5
|
+
export default class Compositor {
|
|
6
|
+
/**
|
|
7
|
+
* @param {WebGLRenderer} renderer - the current WebGL renderer session
|
|
8
|
+
* @param {Object} settings - additional settings to initialize this compositors
|
|
9
|
+
* @param {object[]} attribute - an array of attributes definition
|
|
10
|
+
* @param {string} attribute.name - name of the attribute in the vertex shader
|
|
11
|
+
* @param {number} attribute.size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
12
|
+
* @param {GLenum} attribute.type - data type of each component in the array
|
|
13
|
+
* @param {boolean} attribute.normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
14
|
+
* @param {number} attribute.offset - offset in bytes of the first component in the vertex attribute array
|
|
15
|
+
* @param {object} shader - an array of attributes definition
|
|
16
|
+
* @param {string} shader.vertex - a string containing the GLSL source code to set
|
|
17
|
+
* @param {string} shader.fragment - a string containing the GLSL source code to set
|
|
18
|
+
*/
|
|
19
|
+
constructor(renderer: WebGLRenderer, settings: Object);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the compositor
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
init(renderer: any, settings: any): void;
|
|
25
|
+
renderer: any;
|
|
26
|
+
gl: any;
|
|
27
|
+
color: any;
|
|
28
|
+
viewMatrix: any;
|
|
29
|
+
/**
|
|
30
|
+
* the default shader created by this compositor
|
|
31
|
+
* @type {GLShader}
|
|
32
|
+
*/
|
|
33
|
+
defaultShader: GLShader | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* the shader currently used by this compositor
|
|
36
|
+
* @type {GLShader}
|
|
37
|
+
*/
|
|
38
|
+
currentShader: GLShader | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @default gl.TRIANGLES
|
|
43
|
+
*/
|
|
44
|
+
mode: number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* an array of vertex attribute properties
|
|
47
|
+
* @see WebGLCompositor.addAttribute
|
|
48
|
+
* @type {Array}
|
|
49
|
+
*/
|
|
50
|
+
attributes: any[] | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* the size of a single vertex in bytes
|
|
53
|
+
* (will automatically be calculated as attributes definitions are added)
|
|
54
|
+
* @see WebGLCompositor.addAttribute
|
|
55
|
+
* @type {number}
|
|
56
|
+
*/
|
|
57
|
+
vertexByteSize: number | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* the size of a single vertex in floats
|
|
60
|
+
* (will automatically be calculated as attributes definitions are added)
|
|
61
|
+
* @see WebGLCompositor.addAttribute
|
|
62
|
+
* @type {number}
|
|
63
|
+
*/
|
|
64
|
+
vertexSize: number | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* the vertex data buffer used by this compositor
|
|
67
|
+
* @type {VertexArrayBuffer}
|
|
68
|
+
*/
|
|
69
|
+
vertexData: VertexArrayBuffer | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Reset compositor internal state
|
|
72
|
+
* @ignore
|
|
73
|
+
*/
|
|
74
|
+
reset(): void;
|
|
75
|
+
/**
|
|
76
|
+
* @ignore
|
|
77
|
+
* called by the WebGL renderer when a compositor become the current one
|
|
78
|
+
*/
|
|
79
|
+
bind(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Select the shader to use for compositing
|
|
82
|
+
* @see GLShader
|
|
83
|
+
* @param {GLShader} shader - a reference to a GLShader instance
|
|
84
|
+
*/
|
|
85
|
+
useShader(shader: GLShader): void;
|
|
86
|
+
/**
|
|
87
|
+
* add vertex attribute property definition to the compositor
|
|
88
|
+
* @param {string} name - name of the attribute in the vertex shader
|
|
89
|
+
* @param {number} size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
90
|
+
* @param {GLenum} type - data type of each component in the array
|
|
91
|
+
* @param {boolean} normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
92
|
+
* @param {number} offset - offset in bytes of the first component in the vertex attribute array
|
|
93
|
+
*/
|
|
94
|
+
addAttribute(name: string, size: number, type: GLenum, normalized: boolean, offset: number): void;
|
|
95
|
+
/**
|
|
96
|
+
* set/change the current projection matrix
|
|
97
|
+
* @param {Matrix3d} matrix
|
|
98
|
+
*/
|
|
99
|
+
setProjection(matrix: Matrix3d): void;
|
|
100
|
+
/**
|
|
101
|
+
* Flush batched vertex data to the GPU
|
|
102
|
+
* @param {number} [mode=gl.TRIANGLES] - the GL drawing mode
|
|
103
|
+
*/
|
|
104
|
+
flush(mode?: number | undefined): void;
|
|
105
|
+
}
|
|
106
|
+
import GLShader from "../glshader.js";
|
|
107
|
+
import VertexArrayBuffer from "../buffer/vertex.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* A WebGL Compositor object. This class handles all of the WebGL state<br>
|
|
4
|
+
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
5
|
+
* @augments Compositor
|
|
6
|
+
*/
|
|
7
|
+
export default class PrimitiveCompositor extends Compositor {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the compositor
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
init(renderer: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* Draw an array of vertices
|
|
15
|
+
* @param {GLenum} mode - primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
16
|
+
* @param {Point[]} verts - an array of vertices
|
|
17
|
+
* @param {number} [vertexCount=verts.length] - amount of points defined in the points array
|
|
18
|
+
*/
|
|
19
|
+
drawVertices(mode: GLenum, verts: Point[], vertexCount?: number | undefined): void;
|
|
20
|
+
mode: any;
|
|
21
|
+
}
|
|
22
|
+
import Compositor from "./compositor.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* A WebGL Compositor object. This class handles all of the WebGL state<br>
|
|
4
|
+
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
5
|
+
* @augments Compositor
|
|
6
|
+
*/
|
|
7
|
+
export default class QuadCompositor extends Compositor {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the compositor
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
init(renderer: any): void;
|
|
13
|
+
currentTextureUnit: any;
|
|
14
|
+
boundTextures: any[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Create a WebGL texture from an image
|
|
17
|
+
* @param {number} unit - Destination texture unit
|
|
18
|
+
* @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} [pixels=null] - Source image
|
|
19
|
+
* @param {number} filter - gl.LINEAR or gl.NEAREST
|
|
20
|
+
* @param {string} [repeat="no-repeat"] - Image repeat behavior (see {@link ImageLayer#repeat})
|
|
21
|
+
* @param {number} [w=pixels.width] - Source image width (Only use with UInt8Array[] or Float32Array[] source image)
|
|
22
|
+
* @param {number} [h=pixels.height] - Source image height (Only use with UInt8Array[] or Float32Array[] source image)
|
|
23
|
+
* @param {boolean} [premultipliedAlpha=true] - Multiplies the alpha channel into the other color channels
|
|
24
|
+
* @param {boolean} [mipmap=true] - Whether mipmap levels should be generated for this texture
|
|
25
|
+
* @returns {WebGLTexture} a WebGL texture
|
|
26
|
+
*/
|
|
27
|
+
createTexture2D(unit: number, pixels?: HTMLCanvasElement | ImageData | (new (width?: number | undefined, height?: number | undefined) => HTMLImageElement) | Uint8Array[] | Float32Array[] | undefined, filter: number, repeat?: string | undefined, w?: number | undefined, h?: number | undefined, premultipliedAlpha?: boolean | undefined, mipmap?: boolean | undefined): WebGLTexture;
|
|
28
|
+
/**
|
|
29
|
+
* delete the given WebGL texture
|
|
30
|
+
* @param {WebGLTexture} [texture] - a WebGL texture to delete
|
|
31
|
+
* @param {number} [unit] - Texture unit to delete
|
|
32
|
+
*/
|
|
33
|
+
deleteTexture2D(texture?: WebGLTexture | undefined): void;
|
|
34
|
+
/**
|
|
35
|
+
* returns the WebGL texture associated to the given texture unit
|
|
36
|
+
* @param {number} unit - Texture unit to which a texture is bound
|
|
37
|
+
* @returns {WebGLTexture} texture a WebGL texture
|
|
38
|
+
*/
|
|
39
|
+
getTexture2D(unit: number): WebGLTexture;
|
|
40
|
+
/**
|
|
41
|
+
* assign the given WebGL texture to the current batch
|
|
42
|
+
* @param {WebGLTexture} texture - a WebGL texture
|
|
43
|
+
* @param {number} unit - Texture unit to which the given texture is bound
|
|
44
|
+
*/
|
|
45
|
+
bindTexture2D(texture: WebGLTexture, unit: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* unbind the given WebGL texture, forcing it to be reuploaded
|
|
48
|
+
* @param {WebGLTexture} [texture] - a WebGL texture
|
|
49
|
+
* @param {number} [unit] - a WebGL texture
|
|
50
|
+
* @returns {number} unit the unit number that was associated with the given texture
|
|
51
|
+
*/
|
|
52
|
+
unbindTexture2D(texture?: WebGLTexture | undefined, unit?: number | undefined): number;
|
|
53
|
+
/**
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
56
|
+
uploadTexture(texture: any, w: any, h: any, force?: boolean): any;
|
|
57
|
+
/**
|
|
58
|
+
* Add a textured quad
|
|
59
|
+
* @param {TextureAtlas} texture - Source texture atlas
|
|
60
|
+
* @param {number} x - Destination x-coordinate
|
|
61
|
+
* @param {number} y - Destination y-coordinate
|
|
62
|
+
* @param {number} w - Destination width
|
|
63
|
+
* @param {number} h - Destination height
|
|
64
|
+
* @param {number} u0 - Texture UV (u0) value.
|
|
65
|
+
* @param {number} v0 - Texture UV (v0) value.
|
|
66
|
+
* @param {number} u1 - Texture UV (u1) value.
|
|
67
|
+
* @param {number} v1 - Texture UV (v1) value.
|
|
68
|
+
* @param {number} tint - tint color to be applied to the texture in UINT32 (argb) format
|
|
69
|
+
*/
|
|
70
|
+
addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number): void;
|
|
71
|
+
}
|
|
72
|
+
import Compositor from "./compositor.js";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* A WebGL Compositor object. This class handles all of the WebGL state<br>
|
|
4
|
+
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
5
|
+
* @augments Compositor
|
|
6
|
+
*/
|
|
7
|
+
export default class WebGLCompositor extends Compositor {
|
|
8
|
+
currentTextureUnit: any;
|
|
9
|
+
boundTextures: any[] | undefined;
|
|
10
|
+
primitiveShader: GLShader | undefined;
|
|
11
|
+
quadShader: GLShader | undefined;
|
|
12
|
+
vertexBuffer: VertexArrayBuffer | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Create a WebGL texture from an image
|
|
15
|
+
* @param {number} unit - Destination texture unit
|
|
16
|
+
* @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image - Source image
|
|
17
|
+
* @param {number} filter - gl.LINEAR or gl.NEAREST
|
|
18
|
+
* @param {string} [repeat="no-repeat"] - Image repeat behavior (see {@link ImageLayer#repeat})
|
|
19
|
+
* @param {number} [w] - Source image width (Only use with UInt8Array[] or Float32Array[] source image)
|
|
20
|
+
* @param {number} [h] - Source image height (Only use with UInt8Array[] or Float32Array[] source image)
|
|
21
|
+
* @param {number} [b] - Source image border (Only use with UInt8Array[] or Float32Array[] source image)
|
|
22
|
+
* @param {boolean} [premultipliedAlpha=true] - Multiplies the alpha channel into the other color channels
|
|
23
|
+
* @param {boolean} [mipmap=true] - Whether mipmap levels should be generated for this texture
|
|
24
|
+
* @returns {WebGLTexture} a WebGL texture
|
|
25
|
+
*/
|
|
26
|
+
createTexture2D(unit: number, image: (new (width?: number | undefined, height?: number | undefined) => HTMLImageElement) | HTMLCanvasElement | ImageData | Uint8Array[] | Float32Array[], filter: number, repeat?: string | undefined, w?: number | undefined, h?: number | undefined, b?: number | undefined, premultipliedAlpha?: boolean | undefined, mipmap?: boolean | undefined): WebGLTexture;
|
|
27
|
+
/**
|
|
28
|
+
* delete the given WebGL texture
|
|
29
|
+
* @param {WebGLTexture} [texture] - a WebGL texture to delete
|
|
30
|
+
* @param {number} [unit] - Texture unit to delete
|
|
31
|
+
*/
|
|
32
|
+
deleteTexture2D(texture?: WebGLTexture | undefined): void;
|
|
33
|
+
/**
|
|
34
|
+
* returns the WebGL texture associated to the given texture unit
|
|
35
|
+
* @param {number} unit - Texture unit to which a texture is bound
|
|
36
|
+
* @returns {WebGLTexture} texture a WebGL texture
|
|
37
|
+
*/
|
|
38
|
+
getTexture2D(unit: number): WebGLTexture;
|
|
39
|
+
/**
|
|
40
|
+
* assign the given WebGL texture to the current batch
|
|
41
|
+
* @param {WebGLTexture} texture - a WebGL texture
|
|
42
|
+
* @param {number} unit - Texture unit to which the given texture is bound
|
|
43
|
+
*/
|
|
44
|
+
bindTexture2D(texture: WebGLTexture, unit: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* unbind the given WebGL texture, forcing it to be reuploaded
|
|
47
|
+
* @param {WebGLTexture} [texture] - a WebGL texture
|
|
48
|
+
* @param {number} [unit] - a WebGL texture
|
|
49
|
+
* @returns {number} unit the unit number that was associated with the given texture
|
|
50
|
+
*/
|
|
51
|
+
unbindTexture2D(texture?: WebGLTexture | undefined, unit?: number | undefined): number;
|
|
52
|
+
/**
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
uploadTexture(texture: any, w: any, h: any, b: any, force?: boolean): any;
|
|
56
|
+
/**
|
|
57
|
+
* Select the shader to use for compositing
|
|
58
|
+
* @see GLShader
|
|
59
|
+
* @param {GLShader} shader - a reference to a GLShader instance
|
|
60
|
+
*/
|
|
61
|
+
useShader(shader: GLShader): void;
|
|
62
|
+
/**
|
|
63
|
+
* Add a textured quad
|
|
64
|
+
* @param {TextureAtlas} texture - Source texture atlas
|
|
65
|
+
* @param {number} x - Destination x-coordinate
|
|
66
|
+
* @param {number} y - Destination y-coordinate
|
|
67
|
+
* @param {number} w - Destination width
|
|
68
|
+
* @param {number} h - Destination height
|
|
69
|
+
* @param {number} u0 - Texture UV (u0) value.
|
|
70
|
+
* @param {number} v0 - Texture UV (v0) value.
|
|
71
|
+
* @param {number} u1 - Texture UV (u1) value.
|
|
72
|
+
* @param {number} v1 - Texture UV (v1) value.
|
|
73
|
+
* @param {number} tint - tint color to be applied to the texture in UINT32 (argb) format
|
|
74
|
+
*/
|
|
75
|
+
addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Draw an array of vertices
|
|
78
|
+
* @param {GLenum} mode - primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
79
|
+
* @param {Point[]} verts - an array of vertices
|
|
80
|
+
* @param {number} [vertexCount=verts.length] - amount of points defined in the points array
|
|
81
|
+
*/
|
|
82
|
+
drawVertices(mode: GLenum, verts: Point[], vertexCount?: number | undefined): void;
|
|
83
|
+
}
|
|
84
|
+
import Compositor from "./compositor.js";
|
|
85
|
+
import GLShader from "../glshader.js";
|
|
86
|
+
import VertexArrayBuffer from "../buffer/vertex.js";
|
|
@@ -151,10 +151,10 @@ export default class WebGLCompositor {
|
|
|
151
151
|
/**
|
|
152
152
|
* Draw an array of vertices
|
|
153
153
|
* @param {GLenum} mode - primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
154
|
-
* @param {
|
|
154
|
+
* @param {Point[]} verts - an array of vertices
|
|
155
155
|
* @param {number} [vertexCount=verts.length] - amount of points defined in the points array
|
|
156
156
|
*/
|
|
157
|
-
drawVertices(mode: GLenum, verts:
|
|
157
|
+
drawVertices(mode: GLenum, verts: Point[], vertexCount?: number | undefined): void;
|
|
158
158
|
/**
|
|
159
159
|
* Clear the frame buffer
|
|
160
160
|
* @param {number} [alpha = 0.0] - the alpha value used when clearing the framebuffer
|
|
@@ -171,4 +171,3 @@ export default class WebGLCompositor {
|
|
|
171
171
|
}
|
|
172
172
|
import GLShader from "./glshader.js";
|
|
173
173
|
import VertexArrayBuffer from "./buffer/vertex.js";
|
|
174
|
-
import Vector2d from "./../../math/vector2.js";
|
|
@@ -18,7 +18,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
18
18
|
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
19
19
|
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
20
20
|
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {Compositor} [options.compositor] - A class that implements the compositor API for sprite rendering
|
|
22
22
|
*/
|
|
23
23
|
constructor(options: {
|
|
24
24
|
width: number;
|
|
@@ -33,7 +33,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
33
33
|
powerPreference?: string | undefined;
|
|
34
34
|
zoomX?: number | undefined;
|
|
35
35
|
zoomY?: number | undefined;
|
|
36
|
-
compositor?:
|
|
36
|
+
compositor?: any;
|
|
37
37
|
});
|
|
38
38
|
/**
|
|
39
39
|
* The WebGL version used by this renderer (1 or 2)
|
|
@@ -45,14 +45,14 @@ export default class WebGLRenderer extends Renderer {
|
|
|
45
45
|
/**
|
|
46
46
|
* The vendor string of the underlying graphics driver.
|
|
47
47
|
* @type {string}
|
|
48
|
-
* @default
|
|
48
|
+
* @default undefined
|
|
49
49
|
* @readonly
|
|
50
50
|
*/
|
|
51
51
|
readonly GPUVendor: string;
|
|
52
52
|
/**
|
|
53
53
|
* The renderer string of the underlying graphics driver.
|
|
54
54
|
* @type {string}
|
|
55
|
-
* @default
|
|
55
|
+
* @default undefined
|
|
56
56
|
* @readonly
|
|
57
57
|
*/
|
|
58
58
|
readonly GPURenderer: string;
|
|
@@ -63,6 +63,11 @@ export default class WebGLRenderer extends Renderer {
|
|
|
63
63
|
*/
|
|
64
64
|
context: WebGLRenderingContext;
|
|
65
65
|
gl: WebGLRenderingContext;
|
|
66
|
+
/**
|
|
67
|
+
* the vertex buffer used by this WebGL Renderer
|
|
68
|
+
* @type {WebGLBuffer}
|
|
69
|
+
*/
|
|
70
|
+
vertexBuffer: WebGLBuffer;
|
|
66
71
|
/**
|
|
67
72
|
* Maximum number of texture unit supported under the current context
|
|
68
73
|
* @type {number}
|
|
@@ -95,33 +100,36 @@ export default class WebGLRenderer extends Renderer {
|
|
|
95
100
|
* @type {WebGLCompositor}
|
|
96
101
|
*/
|
|
97
102
|
currentCompositor: WebGLCompositor;
|
|
103
|
+
/**
|
|
104
|
+
* a reference to the current shader program used by the renderer
|
|
105
|
+
* @type {WebGLProgram}
|
|
106
|
+
*/
|
|
107
|
+
currentProgram: WebGLProgram;
|
|
98
108
|
/**
|
|
99
109
|
* The list of active compositors
|
|
100
110
|
* @type {Map<WebGLCompositor>}
|
|
101
111
|
*/
|
|
102
112
|
compositors: Map<WebGLCompositor, any>;
|
|
113
|
+
customShader: any;
|
|
103
114
|
cache: TextureCache;
|
|
115
|
+
/**
|
|
116
|
+
* add a new compositor to this renderer
|
|
117
|
+
* @param {Compositor} compositor - a compositor instance
|
|
118
|
+
* @param {String} name - a name uniquely identifying this compositor
|
|
119
|
+
* @param {Boolean} [activate=false] - true if the given compositor should be set as the active one
|
|
120
|
+
*/
|
|
121
|
+
addCompositor(compositor: Compositor, name?: string, activate?: boolean | undefined): void;
|
|
104
122
|
/**
|
|
105
123
|
* set the active compositor for this renderer
|
|
106
|
-
* @param {
|
|
124
|
+
* @param {String} name - a compositor name
|
|
125
|
+
* @param {GLShader} [shader] - an optional shader program to be used, instead of the default one, when activating the compositor
|
|
126
|
+
* @return {Compositor} an instance to the current active compositor
|
|
107
127
|
*/
|
|
108
|
-
setCompositor(
|
|
128
|
+
setCompositor(name?: string, shader?: any): Compositor;
|
|
109
129
|
/**
|
|
110
130
|
* Reset the gl transform to identity
|
|
111
131
|
*/
|
|
112
132
|
resetTransform(): void;
|
|
113
|
-
/**
|
|
114
|
-
* @ignore
|
|
115
|
-
*/
|
|
116
|
-
createFontTexture(cache: any): void;
|
|
117
|
-
/**
|
|
118
|
-
* @ignore
|
|
119
|
-
*/
|
|
120
|
-
fontContext2D: CanvasRenderingContext2D | undefined;
|
|
121
|
-
/**
|
|
122
|
-
* @ignore
|
|
123
|
-
*/
|
|
124
|
-
fontTexture: TextureAtlas | undefined;
|
|
125
133
|
/**
|
|
126
134
|
* Create a pattern with the specified repetition
|
|
127
135
|
* @param {Image} image - Source image
|
|
@@ -140,6 +148,14 @@ export default class WebGLRenderer extends Renderer {
|
|
|
140
148
|
* @param {Matrix3d} matrix
|
|
141
149
|
*/
|
|
142
150
|
setProjection(matrix: Matrix3d): void;
|
|
151
|
+
/**
|
|
152
|
+
* Sets the WebGL viewport, which specifies the affine transformation of x and y from normalized device coordinates to window coordinates
|
|
153
|
+
* @param {number} [x = 0] - x the horizontal coordinate for the lower left corner of the viewport origin
|
|
154
|
+
* @param {number} [y = 0] - y the vertical coordinate for the lower left corner of the viewport origin
|
|
155
|
+
* @param {number} [w = width of the canvas] - the width of viewport
|
|
156
|
+
* @param {number} [h = height of the canvas] - the height of viewport
|
|
157
|
+
*/
|
|
158
|
+
setViewport(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: number | undefined): void;
|
|
143
159
|
/**
|
|
144
160
|
* Clears the gl context with the given color.
|
|
145
161
|
* @param {Color|string} [color="#000000"] - CSS color.
|
|
@@ -154,10 +170,6 @@ export default class WebGLRenderer extends Renderer {
|
|
|
154
170
|
* @param {number} height - The rectangle's height.
|
|
155
171
|
*/
|
|
156
172
|
clearRect(x: number, y: number, width: number, height: number): void;
|
|
157
|
-
/**
|
|
158
|
-
* @ignore
|
|
159
|
-
*/
|
|
160
|
-
drawFont(bounds: any): void;
|
|
161
173
|
/**
|
|
162
174
|
* Draw an image to the gl context
|
|
163
175
|
* @param {Image} image - An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
|
|
@@ -218,11 +230,6 @@ export default class WebGLRenderer extends Renderer {
|
|
|
218
230
|
*/
|
|
219
231
|
setBlendMode(mode?: string | undefined, gl?: WebGLRenderingContext | undefined): void;
|
|
220
232
|
currentBlendMode: any;
|
|
221
|
-
/**
|
|
222
|
-
* return a reference to the font 2d Context
|
|
223
|
-
* @ignore
|
|
224
|
-
*/
|
|
225
|
-
getFontContext(): CanvasRenderingContext2D | undefined;
|
|
226
233
|
/**
|
|
227
234
|
* restores the canvas context
|
|
228
235
|
*/
|
|
@@ -423,7 +430,6 @@ export default class WebGLRenderer extends Renderer {
|
|
|
423
430
|
}
|
|
424
431
|
import Renderer from "./../renderer.js";
|
|
425
432
|
import Matrix2d from "./../../math/matrix2.js";
|
|
426
|
-
import WebGLCompositor from "./webgl_compositor.js";
|
|
427
433
|
import TextureCache from "./../texture/cache.js";
|
|
428
434
|
import { TextureAtlas } from "./../texture/atlas.js";
|
|
429
435
|
import Color from "./../../math/color.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"type": "module",
|
|
@@ -53,44 +53,44 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@teppeis/multimaps": "^2.0.0",
|
|
56
|
-
"core-js": "^3.
|
|
56
|
+
"core-js": "^3.29.1",
|
|
57
57
|
"earcut": "2.2.4",
|
|
58
58
|
"eventemitter3": "^5.0.0",
|
|
59
59
|
"howler": "2.2.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/eslint-parser": "^7.
|
|
62
|
+
"@babel/eslint-parser": "^7.21.3",
|
|
63
63
|
"@babel/plugin-syntax-import-assertions": "^7.20.0",
|
|
64
|
-
"@fastify/static": "^6.
|
|
64
|
+
"@fastify/static": "^6.9.0",
|
|
65
65
|
"@melonjs/webdoc-theme": "^1.1.1",
|
|
66
|
-
"@rollup/plugin-commonjs": "^24.0.
|
|
67
|
-
"@rollup/plugin-image": "^3.0.
|
|
66
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
67
|
+
"@rollup/plugin-image": "^3.0.2",
|
|
68
68
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
69
69
|
"@rollup/plugin-replace": "^5.0.2",
|
|
70
|
-
"@types/offscreencanvas": "^2019.7.0",
|
|
71
70
|
"@webdoc/cli": "^2.2.0",
|
|
72
|
-
"chromedriver": "^
|
|
71
|
+
"chromedriver": "^111.0.0",
|
|
73
72
|
"cross-env": "^7.0.3",
|
|
74
73
|
"del-cli": "^5.0.0",
|
|
75
|
-
"eslint": "^8.
|
|
76
|
-
"eslint-plugin-jsdoc": "^
|
|
77
|
-
"expect": "^29.
|
|
78
|
-
"expect-mocha-image-snapshot": "^3.0.
|
|
79
|
-
"fastify": "^4.
|
|
74
|
+
"eslint": "^8.36.0",
|
|
75
|
+
"eslint-plugin-jsdoc": "^40.0.3",
|
|
76
|
+
"expect": "^29.5.0",
|
|
77
|
+
"expect-mocha-image-snapshot": "^3.0.3",
|
|
78
|
+
"fastify": "^4.14.1",
|
|
80
79
|
"mocha": "^10.2.0",
|
|
81
80
|
"npm-self-link": "^1.1.7",
|
|
82
|
-
"puppeteer": "^19.5
|
|
83
|
-
"rollup": "^3.
|
|
81
|
+
"puppeteer": "^19.7.5",
|
|
82
|
+
"rollup": "^3.19.1",
|
|
84
83
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
85
84
|
"rollup-plugin-string": "^3.0.0",
|
|
86
|
-
"terser": "^5.16.
|
|
87
|
-
"typescript": "^
|
|
85
|
+
"terser": "^5.16.6",
|
|
86
|
+
"typescript": "^5.0.2"
|
|
88
87
|
},
|
|
89
88
|
"scripts": {
|
|
90
89
|
"build": "npm run lint && rollup -c --silent",
|
|
90
|
+
"build:cd": "npm run lint && rollup -c --failAfterWarnings",
|
|
91
91
|
"dist": " npm run build && mkdirp dist && cp -fR build/*.* dist/ && npm run types",
|
|
92
92
|
"lint": "eslint src/** rollup.config.mjs",
|
|
93
|
-
"pretest": "cp -f
|
|
93
|
+
"pretest": "mkdirp tests/browser/public/lib && cp -f build/melonjs.module.js tests/browser/public/lib",
|
|
94
94
|
"test": "npm run test-node && mocha ./tests/browser/spec/*.js --reporter spec --bail --timeout 10000",
|
|
95
95
|
"test-node": "node build/melonjs.module.js",
|
|
96
96
|
"doc-prod": "mkdirp docs && webdoc --quiet --site-root melonJS/docs -R README.md",
|
package/src/audio/audio.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// external import
|
|
2
2
|
import {Howl, Howler} from "howler";
|
|
3
3
|
import {clamp} from "./../math/math.js";
|
|
4
|
-
import
|
|
4
|
+
import { nocache, withCredentials} from "./../loader/settings.js";
|
|
5
5
|
import { isDataUrl } from "./../utils/string.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -154,7 +154,7 @@ export function load(sound, html5, onload_cb, onerror_cb) {
|
|
|
154
154
|
urls.push(sound.src);
|
|
155
155
|
} else {
|
|
156
156
|
for (var i = 0; i < audioExts.length; i++) {
|
|
157
|
-
urls.push(sound.src + sound.name + "." + audioExts[i] +
|
|
157
|
+
urls.push(sound.src + sound.name + "." + audioExts[i] + nocache);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -162,7 +162,7 @@ export function load(sound, html5, onload_cb, onerror_cb) {
|
|
|
162
162
|
src : urls,
|
|
163
163
|
volume : Howler.volume(),
|
|
164
164
|
html5 : html5 === true,
|
|
165
|
-
xhrWithCredentials :
|
|
165
|
+
xhrWithCredentials : withCredentials,
|
|
166
166
|
/**
|
|
167
167
|
* @ignore
|
|
168
168
|
*/
|
|
@@ -455,9 +455,7 @@ export function getVolume() {
|
|
|
455
455
|
* // mute the background music
|
|
456
456
|
* me.audio.mute("awesome_music");
|
|
457
457
|
*/
|
|
458
|
-
export function mute(sound_name, id, mute) {
|
|
459
|
-
// if not defined : true
|
|
460
|
-
mute = (typeof(mute) === "undefined" ? true : !!mute);
|
|
458
|
+
export function mute(sound_name, id, mute = true) {
|
|
461
459
|
var sound = audioTracks[sound_name];
|
|
462
460
|
if (sound && typeof(sound) !== "undefined") {
|
|
463
461
|
sound.mute(mute, id);
|
package/src/entity/entity.js
CHANGED
|
@@ -53,10 +53,10 @@ import Body from "./../physics/body.js";
|
|
|
53
53
|
|
|
54
54
|
// Update anchorPoint
|
|
55
55
|
if (settings.anchorPoint) {
|
|
56
|
-
this.anchorPoint.
|
|
56
|
+
this.anchorPoint.setMuted(settings.anchorPoint.x, settings.anchorPoint.y);
|
|
57
57
|
} else {
|
|
58
58
|
// for backward compatibility
|
|
59
|
-
this.anchorPoint.
|
|
59
|
+
this.anchorPoint.setMuted(0, 0);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// set the sprite name if specified
|
|
@@ -140,6 +140,7 @@ import Body from "./../physics/body.js";
|
|
|
140
140
|
if (value instanceof Renderable) {
|
|
141
141
|
this.children[0] = value;
|
|
142
142
|
this.children[0].ancestor = this;
|
|
143
|
+
this.updateBounds();
|
|
143
144
|
} else {
|
|
144
145
|
throw new Error(value + "should extend me.Renderable");
|
|
145
146
|
}
|
|
@@ -154,17 +155,50 @@ import Body from "./../physics/body.js";
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/**
|
|
157
|
-
* update the
|
|
158
|
+
* update the bounding box for this entity.
|
|
159
|
+
* @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
|
|
160
|
+
* @returns {Bounds} this entity bounding box Rectangle object
|
|
161
|
+
*/
|
|
162
|
+
updateBounds(absolute = true) {
|
|
163
|
+
var bounds = this.getBounds();
|
|
164
|
+
|
|
165
|
+
bounds.clear();
|
|
166
|
+
bounds.addFrame(
|
|
167
|
+
0,
|
|
168
|
+
0,
|
|
169
|
+
this.width,
|
|
170
|
+
this.height
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// add each renderable bounds
|
|
174
|
+
if (this.children && this.children.length > 0) {
|
|
175
|
+
bounds.addBounds(this.children[0].getBounds());
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (this.body) {
|
|
179
|
+
bounds.addBounds(this.body.getBounds());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (absolute === true) {
|
|
183
|
+
bounds.centerOn(this.pos.x + bounds.x + bounds.width / 2, this.pos.y + bounds.y + bounds.height / 2);
|
|
184
|
+
if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
|
|
185
|
+
bounds.translate(this.ancestor.getAbsolutePosition());
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return bounds;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* update the bounds when the body is modified
|
|
158
195
|
* @ignore
|
|
159
196
|
* @name onBodyUpdate
|
|
160
197
|
* @memberof Entity
|
|
161
198
|
* @param {Body} body - the body whose bounds to update
|
|
162
199
|
*/
|
|
163
|
-
onBodyUpdate(
|
|
164
|
-
|
|
165
|
-
this.getBounds().addBounds(body.getBounds(), true);
|
|
166
|
-
// update the bounds pos
|
|
167
|
-
this.updateBoundsPos(this.pos.x, this.pos.y);
|
|
200
|
+
onBodyUpdate() {
|
|
201
|
+
this.updateBounds();
|
|
168
202
|
}
|
|
169
203
|
|
|
170
204
|
preDraw(renderer) {
|
|
@@ -126,8 +126,7 @@ import pool from "./../system/pooling.js";
|
|
|
126
126
|
* @param {number} [y=x]
|
|
127
127
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
128
128
|
*/
|
|
129
|
-
scale(x, y) {
|
|
130
|
-
y = typeof (y) !== "undefined" ? y : x;
|
|
129
|
+
scale(x, y = x) {
|
|
131
130
|
return this.setShape(
|
|
132
131
|
this.pos.x,
|
|
133
132
|
this.pos.y,
|