melonjs 15.2.1 → 15.3.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 +1 -1
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.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/application/application.js +24 -20
- package/dist/melonjs.mjs/application/header.js +1 -1
- package/dist/melonjs.mjs/application/resize.js +10 -4
- package/dist/melonjs.mjs/application/settings.js +37 -1
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +1 -1
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +1 -1
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +2 -2
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +12 -19
- 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 +1 -1
- package/dist/melonjs.mjs/loader/loader.js +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +1 -1
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +4 -4
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +1 -1
- package/dist/melonjs.mjs/math/matrix3.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
- package/dist/melonjs.mjs/math/vector2.js +1 -1
- package/dist/melonjs.mjs/math/vector3.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/physics/bounds.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +1 -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 +6 -14
- package/dist/melonjs.mjs/renderable/sprite.js +1 -1
- 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 -1
- package/dist/melonjs.mjs/state/stage.js +12 -13
- package/dist/melonjs.mjs/state/state.js +4 -14
- package/dist/melonjs.mjs/system/device.js +3 -1
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +24 -2
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +2 -11
- package/dist/melonjs.mjs/video/renderer.js +2 -15
- package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- 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 -26
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
- 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 +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 +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 +13 -16
- package/dist/melonjs.module.js +142 -144
- package/dist/types/application/application.d.ts +4 -27
- package/dist/types/application/settings.d.ts +64 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
- package/dist/types/renderable/renderable.d.ts +1 -2
- package/dist/types/state/stage.d.ts +3 -2
- package/dist/types/system/device.d.ts +1 -0
- package/dist/types/system/event.d.ts +20 -0
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +3 -30
- package/dist/types/video/video.d.ts +2 -36
- package/dist/types/video/webgl/webgl_renderer.d.ts +1 -34
- package/package.json +6 -6
- package/src/application/application.js +22 -18
- package/src/application/resize.js +8 -2
- package/src/application/settings.js +36 -0
- package/src/level/tiled/TMXUtils.js +11 -18
- package/src/math/color.js +3 -3
- package/src/renderable/renderable.js +5 -13
- package/src/state/stage.js +11 -12
- package/src/state/state.js +2 -12
- package/src/system/device.js +2 -0
- package/src/system/event.js +22 -0
- package/src/video/canvas/canvas_renderer.js +1 -10
- package/src/video/renderer.js +1 -14
- package/src/video/video.js +4 -25
- package/src/video/webgl/webgl_renderer.js +12 -15
|
@@ -4,6 +4,7 @@ export namespace defaultSettings {
|
|
|
4
4
|
const autoScale: boolean;
|
|
5
5
|
const scale: number;
|
|
6
6
|
const scaleMethod: string;
|
|
7
|
+
const scaleTarget: undefined;
|
|
7
8
|
const transparent: boolean;
|
|
8
9
|
const premultipliedAlpha: boolean;
|
|
9
10
|
const blendMode: string;
|
|
@@ -16,3 +17,66 @@ export namespace defaultSettings {
|
|
|
16
17
|
const consoleHeader: boolean;
|
|
17
18
|
const legacy: boolean;
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Application & Renderer Settings definition.
|
|
22
|
+
*/
|
|
23
|
+
export type Settings = {
|
|
24
|
+
/**
|
|
25
|
+
* - the DOM parent element to hold the canvas in the HTML file
|
|
26
|
+
*/
|
|
27
|
+
parent?: string | HTMLElement | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
30
|
+
*/
|
|
31
|
+
renderer?: number | Renderer;
|
|
32
|
+
/**
|
|
33
|
+
* - enable scaling of the canvas ('auto' for automatic scaling)
|
|
34
|
+
*/
|
|
35
|
+
scale?: string | number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch') : <br>
|
|
38
|
+
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
39
|
+
* <center><img src="images/scale-fit.png"/></center><br>
|
|
40
|
+
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
41
|
+
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
42
|
+
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
43
|
+
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
44
|
+
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
45
|
+
* <center><img src="images/scale-flex.png"/></center><br>
|
|
46
|
+
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
47
|
+
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
48
|
+
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
49
|
+
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
50
|
+
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio <br>
|
|
51
|
+
* <center><img src="images/scale-stretch.png"/></center>
|
|
52
|
+
*/
|
|
53
|
+
scaleMethod?: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* - the HTML Element to be used as the reference target when using automatic scaling (by default melonJS will use the parent container of the div element containing the canvas)
|
|
56
|
+
*/
|
|
57
|
+
scaleTarget?: string | HTMLElement | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* - if true the renderer will only use WebGL 1
|
|
60
|
+
*/
|
|
61
|
+
preferWebGL1?: boolean | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
64
|
+
*/
|
|
65
|
+
depthTest?: boolean | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* - 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.
|
|
68
|
+
*/
|
|
69
|
+
powerPreference?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* - whether to allow transparent pixels in the front buffer (screen).
|
|
72
|
+
*/
|
|
73
|
+
transparent?: boolean | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* - whether to enable or not video scaling interpolation
|
|
76
|
+
*/
|
|
77
|
+
antiAlias?: boolean | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* - whether to display melonJS version and basic device information in the console
|
|
80
|
+
*/
|
|
81
|
+
consoleHeader?: boolean | undefined;
|
|
82
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* set the function used to inflate gzip/zlib data
|
|
3
|
+
* @memberof TMXUtils
|
|
3
4
|
* @param {Func} fn - inflate function
|
|
4
5
|
*/
|
|
5
6
|
export function setInflateFunction(fn: Func): void;
|
|
6
7
|
/**
|
|
7
8
|
* Decode a encoded array into a binary array
|
|
8
|
-
* @
|
|
9
|
-
* @memberOf TMXUtils
|
|
9
|
+
* @memberof TMXUtils
|
|
10
10
|
* @param {string} data - data to be decoded
|
|
11
11
|
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
12
12
|
* @returns {number[]} Decoded data
|
|
@@ -14,16 +14,14 @@ export function setInflateFunction(fn: Func): void;
|
|
|
14
14
|
export function decode(data: string, encoding?: string | undefined, compression: any): number[];
|
|
15
15
|
/**
|
|
16
16
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
17
|
-
* @
|
|
18
|
-
* @memberOf TMXUtils
|
|
17
|
+
* @memberof TMXUtils
|
|
19
18
|
* @param {Document} xml - XML TMX object
|
|
20
19
|
* @returns {object} Javascript object
|
|
21
20
|
*/
|
|
22
21
|
export function parse(xml: Document): object;
|
|
23
22
|
/**
|
|
24
23
|
* Apply TMX Properties to the given object
|
|
25
|
-
* @
|
|
26
|
-
* @memberOf TMXUtils
|
|
24
|
+
* @memberof TMXUtils
|
|
27
25
|
* @param {object} obj - object to apply the properties to
|
|
28
26
|
* @param {object} data - TMX data object
|
|
29
27
|
* @returns {object} obj
|
|
@@ -204,6 +204,7 @@ export default class Renderable extends Rect {
|
|
|
204
204
|
y: boolean;
|
|
205
205
|
};
|
|
206
206
|
_inViewport: boolean;
|
|
207
|
+
_tint: object;
|
|
207
208
|
/**
|
|
208
209
|
* Whether the renderable object is floating (i.e. used screen coordinates), or contained in a floating parent container
|
|
209
210
|
* @see Renderable#floating
|
|
@@ -222,7 +223,6 @@ export default class Renderable extends Rect {
|
|
|
222
223
|
* this.tint.setColor(255, 255, 255);
|
|
223
224
|
*/
|
|
224
225
|
get tint(): Color;
|
|
225
|
-
_tint: object | undefined;
|
|
226
226
|
set inViewport(arg: boolean);
|
|
227
227
|
/**
|
|
228
228
|
* Whether the renderable object is visible and within the viewport
|
|
@@ -411,4 +411,3 @@ export default class Renderable extends Rect {
|
|
|
411
411
|
import Rect from "./../geometries/rectangle.js";
|
|
412
412
|
import ObservableVector3d from "./../math/observable_vector3.js";
|
|
413
413
|
import ObservableVector2d from "./../math/observable_vector2.js";
|
|
414
|
-
import Color from "./../math/color.js";
|
|
@@ -86,9 +86,10 @@ export default class Stage {
|
|
|
86
86
|
* @name draw
|
|
87
87
|
* @memberof Stage
|
|
88
88
|
* @ignore
|
|
89
|
-
* @param {
|
|
89
|
+
* @param {Renderer} renderer - the renderer object to draw with
|
|
90
|
+
* @param {World} world - the world object to draw
|
|
90
91
|
*/
|
|
91
|
-
draw(renderer:
|
|
92
|
+
draw(renderer: Renderer, world: World): void;
|
|
92
93
|
/**
|
|
93
94
|
* destroy function
|
|
94
95
|
* @ignore
|
|
@@ -63,6 +63,16 @@ export const DOM_READY: string;
|
|
|
63
63
|
* @see event.on
|
|
64
64
|
*/
|
|
65
65
|
export const BOOT: string;
|
|
66
|
+
/**
|
|
67
|
+
* event generated when the system update the engine and the renderer by one step
|
|
68
|
+
* @public
|
|
69
|
+
* @constant
|
|
70
|
+
* @type {string}
|
|
71
|
+
* @name TICK
|
|
72
|
+
* @memberof event
|
|
73
|
+
* @see event.on
|
|
74
|
+
*/
|
|
75
|
+
export const TICK: string;
|
|
66
76
|
/**
|
|
67
77
|
* event when the game is paused <br>
|
|
68
78
|
* Data passed : none <br>
|
|
@@ -117,6 +127,16 @@ export const STATE_RESTART: string;
|
|
|
117
127
|
* @see event.on
|
|
118
128
|
*/
|
|
119
129
|
export const STATE_CHANGE: string;
|
|
130
|
+
/**
|
|
131
|
+
* event for when a stage is resetted
|
|
132
|
+
* @public
|
|
133
|
+
* @constant
|
|
134
|
+
* @type {string}
|
|
135
|
+
* @name STAGE_RESET
|
|
136
|
+
* @memberof event
|
|
137
|
+
* @see event.on
|
|
138
|
+
*/
|
|
139
|
+
export const STAGE_RESET: string;
|
|
120
140
|
/**
|
|
121
141
|
* event for when the video is initialized<br>
|
|
122
142
|
* Data passed : none <br>
|
|
@@ -4,29 +4,6 @@
|
|
|
4
4
|
* @augments Renderer
|
|
5
5
|
*/
|
|
6
6
|
export default class CanvasRenderer extends Renderer {
|
|
7
|
-
/**
|
|
8
|
-
* @param {object} options - The renderer parameters
|
|
9
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
10
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
11
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
12
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
13
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas (performance hit when enabled)
|
|
14
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
15
|
-
* @param {boolean} [options.textureSeamFix=true] - enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
|
|
16
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
17
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
18
|
-
*/
|
|
19
|
-
constructor(options: {
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
canvas?: HTMLCanvasElement | undefined;
|
|
23
|
-
antiAlias?: boolean | undefined;
|
|
24
|
-
transparent?: boolean | undefined;
|
|
25
|
-
subPixel?: boolean | undefined;
|
|
26
|
-
textureSeamFix?: boolean | undefined;
|
|
27
|
-
zoomX?: number | undefined;
|
|
28
|
-
zoomY?: number | undefined;
|
|
29
|
-
});
|
|
30
7
|
context: CanvasRenderingContext2D;
|
|
31
8
|
cache: TextureCache;
|
|
32
9
|
/**
|
|
@@ -4,36 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export default class Renderer {
|
|
6
6
|
/**
|
|
7
|
-
* @param {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
11
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
12
|
-
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] - If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
13
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
14
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
15
|
-
* @param {boolean} [options.blendMode="normal"] - the default blend mode to use ("normal", "multiply")
|
|
16
|
-
* @param {boolean} [options.depthBuffer="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
17
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel rendering (performance hit when enabled)
|
|
18
|
-
* @param {boolean} [options.verbose=false] - Enable the verbose mode that provides additional details as to what the renderer is doing
|
|
19
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
20
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
21
|
-
*/
|
|
22
|
-
constructor(options: {
|
|
23
|
-
width: number;
|
|
24
|
-
height: number;
|
|
25
|
-
canvas?: HTMLCanvasElement | undefined;
|
|
26
|
-
antiAlias?: boolean | undefined;
|
|
27
|
-
failIfMajorPerformanceCaveat?: boolean | undefined;
|
|
28
|
-
transparent?: boolean | undefined;
|
|
29
|
-
premultipliedAlpha?: boolean | undefined;
|
|
30
|
-
blendMode?: boolean | undefined;
|
|
31
|
-
depthBuffer?: boolean | undefined;
|
|
32
|
-
subPixel?: boolean | undefined;
|
|
33
|
-
verbose?: boolean | undefined;
|
|
34
|
-
zoomX?: number | undefined;
|
|
35
|
-
zoomY?: number | undefined;
|
|
36
|
-
});
|
|
7
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
8
|
+
*/
|
|
9
|
+
constructor(options?: any);
|
|
37
10
|
/**
|
|
38
11
|
* The given constructor options
|
|
39
12
|
* @public
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Initialize the "video" system (create a canvas based on the given arguments, and the related renderer). <br>
|
|
3
|
-
* melonJS support various scaling mode, that can be enabled <u>once the scale option is set to <b>`auto`</b></u> : <br>
|
|
4
|
-
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
5
|
-
* <center><img src="images/scale-fit.png"/></center><br>
|
|
6
|
-
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
7
|
-
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
8
|
-
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
9
|
-
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
10
|
-
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
11
|
-
* <center><img src="images/scale-flex.png"/></center><br>
|
|
12
|
-
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
13
|
-
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
14
|
-
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
15
|
-
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
16
|
-
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
17
|
-
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
18
3
|
* @memberof video
|
|
19
4
|
* @param {number} width - The width of the canvas viewport
|
|
20
5
|
* @param {number} height - The height of the canvas viewport
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
23
|
-
* @param {number|Renderer} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO), or a custom renderer class
|
|
24
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
25
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
26
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
27
|
-
* @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.
|
|
28
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
29
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
30
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
6
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
31
7
|
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
32
8
|
* @example
|
|
33
9
|
* // init the video with a 640x480 canvas
|
|
@@ -38,17 +14,7 @@
|
|
|
38
14
|
* scaleMethod : "fit"
|
|
39
15
|
* });
|
|
40
16
|
*/
|
|
41
|
-
export function init(width: number, height: number, options?:
|
|
42
|
-
parent?: string | HTMLElement | undefined;
|
|
43
|
-
renderer?: number | Renderer;
|
|
44
|
-
scale?: string | number | undefined;
|
|
45
|
-
scaleMethod?: string | undefined;
|
|
46
|
-
preferWebGL1?: boolean | undefined;
|
|
47
|
-
powerPreference?: string | undefined;
|
|
48
|
-
transparent?: boolean | undefined;
|
|
49
|
-
antiAlias?: boolean | undefined;
|
|
50
|
-
consoleHeader?: boolean | undefined;
|
|
51
|
-
} | undefined): boolean;
|
|
17
|
+
export function init(width: number, height: number, options?: any): boolean;
|
|
52
18
|
/**
|
|
53
19
|
* Create and return a new Canvas element
|
|
54
20
|
* @memberof video
|
|
@@ -4,39 +4,6 @@
|
|
|
4
4
|
* @augments Renderer
|
|
5
5
|
*/
|
|
6
6
|
export default class WebGLRenderer extends Renderer {
|
|
7
|
-
/**
|
|
8
|
-
* @param {object} options - The renderer parameters
|
|
9
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
10
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
11
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
12
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
13
|
-
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] - If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
14
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
15
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
16
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
17
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
18
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
19
|
-
* @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.
|
|
20
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
21
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
22
|
-
* @param {Compositor} [options.compositor] - A class that implements the compositor API for sprite rendering
|
|
23
|
-
*/
|
|
24
|
-
constructor(options: {
|
|
25
|
-
width: number;
|
|
26
|
-
height: number;
|
|
27
|
-
canvas?: HTMLCanvasElement | undefined;
|
|
28
|
-
antiAlias?: boolean | undefined;
|
|
29
|
-
failIfMajorPerformanceCaveat?: boolean | undefined;
|
|
30
|
-
transparent?: boolean | undefined;
|
|
31
|
-
premultipliedAlpha?: boolean | undefined;
|
|
32
|
-
subPixel?: boolean | undefined;
|
|
33
|
-
preferWebGL1?: boolean | undefined;
|
|
34
|
-
depthTest?: boolean | undefined;
|
|
35
|
-
powerPreference?: string | undefined;
|
|
36
|
-
zoomX?: number | undefined;
|
|
37
|
-
zoomY?: number | undefined;
|
|
38
|
-
compositor?: any;
|
|
39
|
-
});
|
|
40
7
|
/**
|
|
41
8
|
* The WebGL version used by this renderer (1 or 2)
|
|
42
9
|
* @type {number}
|
|
@@ -112,7 +79,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
112
79
|
* @type {Map<WebGLCompositor>}
|
|
113
80
|
*/
|
|
114
81
|
compositors: Map<WebGLCompositor, any>;
|
|
115
|
-
depthTest:
|
|
82
|
+
depthTest: any;
|
|
116
83
|
customShader: any;
|
|
117
84
|
cache: TextureCache;
|
|
118
85
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"type": "module",
|
|
@@ -71,18 +71,18 @@
|
|
|
71
71
|
"chromedriver": "^113.0.0",
|
|
72
72
|
"cross-env": "^7.0.3",
|
|
73
73
|
"del-cli": "^5.0.0",
|
|
74
|
-
"eslint": "^8.
|
|
75
|
-
"eslint-plugin-jsdoc": "^44.2.
|
|
74
|
+
"eslint": "^8.41.0",
|
|
75
|
+
"eslint-plugin-jsdoc": "^44.2.4",
|
|
76
76
|
"expect": "^29.5.0",
|
|
77
77
|
"expect-mocha-image-snapshot": "^3.0.13",
|
|
78
78
|
"fastify": "^4.17.0",
|
|
79
79
|
"mocha": "^10.2.0",
|
|
80
80
|
"npm-self-link": "^1.1.7",
|
|
81
|
-
"puppeteer": "^20.
|
|
82
|
-
"rollup": "^3.
|
|
81
|
+
"puppeteer": "^20.3.0",
|
|
82
|
+
"rollup": "^3.23.0",
|
|
83
83
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
84
84
|
"rollup-plugin-string": "^3.0.0",
|
|
85
|
-
"terser": "^5.17.
|
|
85
|
+
"terser": "^5.17.5",
|
|
86
86
|
"typescript": "^5.0.4"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
@@ -21,17 +21,7 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {number} width - The width of the canvas viewport
|
|
23
23
|
* @param {number} height - The height of the canvas viewport
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
26
|
-
* @param {number|Renderer} [options.renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
27
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
28
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
29
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
30
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
31
|
-
* @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.
|
|
32
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
33
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
34
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
24
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
35
25
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
36
26
|
* @example
|
|
37
27
|
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
@@ -166,6 +156,12 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
166
156
|
this.settings.zoomX = width * this.settings.scale;
|
|
167
157
|
this.settings.zoomY = height * this.settings.scale;
|
|
168
158
|
|
|
159
|
+
// identify parent element and/or the html target for resizing
|
|
160
|
+
this.parentElement = device.getElement(this.settings.parent);
|
|
161
|
+
if (typeof this.settings.scaleTarget !== "undefined" ) {
|
|
162
|
+
this.settings.scaleTarget = device.getElement(this.settings.scaleTarget);
|
|
163
|
+
}
|
|
164
|
+
|
|
169
165
|
if (typeof this.settings.renderer === "number") {
|
|
170
166
|
switch (this.settings.renderer) {
|
|
171
167
|
case AUTO:
|
|
@@ -187,7 +183,6 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
187
183
|
event.on(event.WINDOW_ONORIENTATION_CHANGE, () => onresize(this), this);
|
|
188
184
|
|
|
189
185
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
190
|
-
this.parentElement = device.getElement(this.settings.parent);
|
|
191
186
|
this.parentElement.appendChild(this.renderer.getCanvas());
|
|
192
187
|
|
|
193
188
|
// Mobile browser hacks
|
|
@@ -226,6 +221,16 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
226
221
|
this.isInitialized = true;
|
|
227
222
|
|
|
228
223
|
event.emit(event.GAME_INIT, this);
|
|
224
|
+
event.on(event.STATE_CHANGE, this.repaint, this);
|
|
225
|
+
event.on(event.STATE_RESTART, this.repaint, this);
|
|
226
|
+
event.on(event.STATE_RESUME, this.repaint, this);
|
|
227
|
+
event.on(event.STAGE_RESET, this.reset, this);
|
|
228
|
+
event.on(event.TICK, (time) => {
|
|
229
|
+
// update all game objects
|
|
230
|
+
this.update(time);
|
|
231
|
+
// render all game objects
|
|
232
|
+
this.draw();
|
|
233
|
+
}, this);
|
|
229
234
|
}
|
|
230
235
|
|
|
231
236
|
/**
|
|
@@ -306,9 +311,8 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
306
311
|
/**
|
|
307
312
|
* update all objects related to this game active scene/stage
|
|
308
313
|
* @param {number} time - current timestamp as provided by the RAF callback
|
|
309
|
-
* @param {Stage} stage - the current stage
|
|
310
314
|
*/
|
|
311
|
-
update(time
|
|
315
|
+
update(time) {
|
|
312
316
|
// handle frame skipping if required
|
|
313
317
|
if ((++this.frameCounter % this.frameRate) === 0) {
|
|
314
318
|
// reset the frame counter
|
|
@@ -332,7 +336,8 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
332
336
|
}
|
|
333
337
|
|
|
334
338
|
// update all objects (and pass the elapsed time since last frame)
|
|
335
|
-
this.isDirty =
|
|
339
|
+
this.isDirty = this.world.update(this.updateDelta);
|
|
340
|
+
this.isDirty = state.current().update(this.updateDelta) || this.isDirty;
|
|
336
341
|
|
|
337
342
|
this.lastUpdate = globalThis.performance.now();
|
|
338
343
|
this.updateAverageDelta = this.lastUpdate - this.lastUpdateStart;
|
|
@@ -351,9 +356,8 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
351
356
|
|
|
352
357
|
/**
|
|
353
358
|
* draw the active scene/stage associated to this game
|
|
354
|
-
* @param {Stage} stage - the current stage
|
|
355
359
|
*/
|
|
356
|
-
draw(
|
|
360
|
+
draw() {
|
|
357
361
|
if (this.renderer.isContextValid === true && (this.isDirty || this.isAlwaysDirty)) {
|
|
358
362
|
// publish notification
|
|
359
363
|
event.emit(event.GAME_BEFORE_DRAW, globalThis.performance.now());
|
|
@@ -362,7 +366,7 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
362
366
|
this.renderer.clear();
|
|
363
367
|
|
|
364
368
|
// render the stage
|
|
365
|
-
|
|
369
|
+
state.current().draw(this.renderer, this.world);
|
|
366
370
|
|
|
367
371
|
// set back to flag
|
|
368
372
|
this.isDirty = false;
|
|
@@ -43,6 +43,7 @@ export function onresize(game) {
|
|
|
43
43
|
let renderer = game.renderer;
|
|
44
44
|
let settings = renderer.settings;
|
|
45
45
|
let scaleX = 1, scaleY = 1;
|
|
46
|
+
let nodeBounds;
|
|
46
47
|
|
|
47
48
|
if (settings.autoScale) {
|
|
48
49
|
|
|
@@ -56,8 +57,13 @@ export function onresize(game) {
|
|
|
56
57
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
if (typeof game.settings.scaleTarget !== "undefined") {
|
|
61
|
+
// get the bounds of the given scale target
|
|
62
|
+
nodeBounds = device.getElementBounds(game.settings.scaleTarget);
|
|
63
|
+
} else {
|
|
64
|
+
// get the maximum canvas size within the parent div containing the canvas container
|
|
65
|
+
nodeBounds = device.getParentBounds(game.getParentElement());
|
|
66
|
+
}
|
|
61
67
|
|
|
62
68
|
let _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
63
69
|
let _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
@@ -5,6 +5,7 @@ export const defaultSettings = {
|
|
|
5
5
|
autoScale : false,
|
|
6
6
|
scale : 1.0,
|
|
7
7
|
scaleMethod : "manual",
|
|
8
|
+
scaleTarget : undefined,
|
|
8
9
|
transparent : false,
|
|
9
10
|
premultipliedAlpha: true,
|
|
10
11
|
blendMode : "normal",
|
|
@@ -17,3 +18,38 @@ export const defaultSettings = {
|
|
|
17
18
|
consoleHeader : true,
|
|
18
19
|
legacy : false
|
|
19
20
|
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Application & Renderer Settings definition.
|
|
24
|
+
* @typedef {Object} Settings
|
|
25
|
+
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
26
|
+
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
27
|
+
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
28
|
+
* @property {string} [scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch') : <br>
|
|
29
|
+
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
30
|
+
* <center><img src="images/scale-fit.png"/></center><br>
|
|
31
|
+
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
32
|
+
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
33
|
+
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
34
|
+
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
35
|
+
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
36
|
+
* <center><img src="images/scale-flex.png"/></center><br>
|
|
37
|
+
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
38
|
+
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
39
|
+
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
40
|
+
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
41
|
+
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio <br>
|
|
42
|
+
* <center><img src="images/scale-stretch.png"/></center>
|
|
43
|
+
* @property {string|HTMLElement} [scaleTarget] - the HTML Element to be used as the reference target when using automatic scaling (by default melonJS will use the parent container of the div element containing the canvas)
|
|
44
|
+
* @property {boolean} [preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
45
|
+
* @property {boolean} [depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
46
|
+
* @property {string} [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.
|
|
47
|
+
* @property {boolean} [transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
48
|
+
* @property {boolean} [antiAlias=false] - whether to enable or not video scaling interpolation
|
|
49
|
+
* @property {boolean} [consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
50
|
+
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
51
|
+
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
52
|
+
* @param {Compositor} [options.compositor] - a custom compositor class (WebGL only)
|
|
53
|
+
* @see Application
|
|
54
|
+
* @memberof Application
|
|
55
|
+
*/
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { isBoolean, isNumeric } from "../../utils/string.js";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* a collection of utility functions for parsing TMX maps
|
|
5
|
-
* @namespace TMXUtils
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
3
|
/**
|
|
10
4
|
* the function used to decompress zlib/gzip data
|
|
11
5
|
* @ignore
|
|
@@ -239,11 +233,14 @@ function normalize(obj, item) {
|
|
|
239
233
|
}
|
|
240
234
|
}
|
|
241
235
|
|
|
236
|
+
/**
|
|
237
|
+
* a collection of utility functions for parsing TMX maps
|
|
238
|
+
* @namespace TMXUtils
|
|
239
|
+
*/
|
|
242
240
|
|
|
243
241
|
/**
|
|
244
242
|
* decompress and decode zlib/gzip data
|
|
245
|
-
* @
|
|
246
|
-
* @memberOf TMXUtils
|
|
243
|
+
* @memberof TMXUtils
|
|
247
244
|
* @param {string} input - Base64 encoded and compressed data
|
|
248
245
|
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
249
246
|
* @returns {Uint32Array} Decoded and decompress data
|
|
@@ -258,8 +255,7 @@ function decompress(data, format) {
|
|
|
258
255
|
|
|
259
256
|
/**
|
|
260
257
|
* Decode a CSV encoded array into a binary array
|
|
261
|
-
* @
|
|
262
|
-
* @memberOf TMXUtils
|
|
258
|
+
* @memberof TMXUtils
|
|
263
259
|
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
264
260
|
* @returns {number[]} Decoded data
|
|
265
261
|
*/
|
|
@@ -275,8 +271,7 @@ function decodeCSV(input) {
|
|
|
275
271
|
|
|
276
272
|
/**
|
|
277
273
|
* Decode a base64 encoded string into a byte array
|
|
278
|
-
* @
|
|
279
|
-
* @memberOf TMXUtils
|
|
274
|
+
* @memberof TMXUtils
|
|
280
275
|
* @param {string} input - Base64 encoded data
|
|
281
276
|
* @param {number} [bytes] - number of bytes per array entry
|
|
282
277
|
* @returns {Uint32Array} Decoded data
|
|
@@ -299,6 +294,7 @@ function decodeBase64AsArray(input, bytes) {
|
|
|
299
294
|
|
|
300
295
|
/**
|
|
301
296
|
* set the function used to inflate gzip/zlib data
|
|
297
|
+
* @memberof TMXUtils
|
|
302
298
|
* @param {Func} fn - inflate function
|
|
303
299
|
*/
|
|
304
300
|
export function setInflateFunction(fn) {
|
|
@@ -307,8 +303,7 @@ export function setInflateFunction(fn) {
|
|
|
307
303
|
|
|
308
304
|
/**
|
|
309
305
|
* Decode a encoded array into a binary array
|
|
310
|
-
* @
|
|
311
|
-
* @memberOf TMXUtils
|
|
306
|
+
* @memberof TMXUtils
|
|
312
307
|
* @param {string} data - data to be decoded
|
|
313
308
|
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
314
309
|
* @returns {number[]} Decoded data
|
|
@@ -342,8 +337,7 @@ export function decode(data, encoding, compression) {
|
|
|
342
337
|
|
|
343
338
|
/**
|
|
344
339
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
345
|
-
* @
|
|
346
|
-
* @memberOf TMXUtils
|
|
340
|
+
* @memberof TMXUtils
|
|
347
341
|
* @param {Document} xml - XML TMX object
|
|
348
342
|
* @returns {object} Javascript object
|
|
349
343
|
*/
|
|
@@ -383,8 +377,7 @@ export function parse(xml) {
|
|
|
383
377
|
|
|
384
378
|
/**
|
|
385
379
|
* Apply TMX Properties to the given object
|
|
386
|
-
* @
|
|
387
|
-
* @memberOf TMXUtils
|
|
380
|
+
* @memberof TMXUtils
|
|
388
381
|
* @param {object} obj - object to apply the properties to
|
|
389
382
|
* @param {object} data - TMX data object
|
|
390
383
|
* @returns {object} obj
|