melonjs 15.2.1 → 15.4.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 +75 -23
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +13 -11
- package/dist/melonjs.mjs/application/settings.js +37 -1
- package/dist/melonjs.mjs/audio/audio.js +4 -6
- package/dist/melonjs.mjs/camera/camera2d.js +12 -14
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
- package/dist/melonjs.mjs/geometries/line.js +18 -25
- package/dist/melonjs.mjs/geometries/path2d.js +16 -13
- package/dist/melonjs.mjs/geometries/point.js +8 -16
- package/dist/melonjs.mjs/geometries/poly.js +40 -97
- package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
- package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
- package/dist/melonjs.mjs/index.js +6 -6
- 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 +3 -3
- package/dist/melonjs.mjs/input/pointer.js +4 -4
- package/dist/melonjs.mjs/input/pointerevent.js +6 -7
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- 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 +16 -33
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -47
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- 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 +4 -5
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +5 -5
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +5 -59
- package/dist/melonjs.mjs/math/matrix3.js +82 -141
- package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
- package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
- package/dist/melonjs.mjs/math/vector2.js +7 -91
- package/dist/melonjs.mjs/math/vector3.js +6 -90
- 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 +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +22 -20
- package/dist/melonjs.mjs/physics/bounds.js +27 -33
- package/dist/melonjs.mjs/physics/collision.js +5 -5
- package/dist/melonjs.mjs/physics/detector.js +10 -10
- package/dist/melonjs.mjs/physics/quadtree.js +5 -5
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +3 -4
- package/dist/melonjs.mjs/physics/world.js +6 -9
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
- package/dist/melonjs.mjs/renderable/container.js +25 -25
- 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 +4 -4
- package/dist/melonjs.mjs/renderable/light2d.js +3 -3
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +31 -39
- package/dist/melonjs.mjs/renderable/sprite.js +3 -3
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
- package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
- package/dist/melonjs.mjs/renderable/text/text.js +422 -0
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
- package/dist/melonjs.mjs/renderable/trigger.js +10 -10
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
- package/dist/melonjs.mjs/state/stage.js +13 -14
- package/dist/melonjs.mjs/state/state.js +4 -51
- package/dist/melonjs.mjs/system/device.js +51 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +46 -2
- package/dist/melonjs.mjs/system/platform.js +18 -18
- package/dist/melonjs.mjs/system/pooling.js +10 -10
- 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 +3 -6
- 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 +2 -2
- 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 +2 -3
- 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 +5 -18
- package/dist/melonjs.mjs/video/renderer.js +17 -30
- package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +5 -29
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
- 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 +4 -4
- 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 +62 -67
- package/dist/melonjs.module.js +1272 -1713
- package/dist/types/application/application.d.ts +32 -31
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +80 -16
- package/dist/types/audio/audio.d.ts +4 -6
- package/dist/types/camera/camera2d.d.ts +13 -16
- package/dist/types/entity/entity.d.ts +0 -1
- package/dist/types/geometries/ellipse.d.ts +18 -50
- package/dist/types/geometries/path2d.d.ts +1 -1
- package/dist/types/geometries/point.d.ts +5 -13
- package/dist/types/geometries/poly.d.ts +26 -75
- package/dist/types/geometries/rectangle.d.ts +12 -58
- package/dist/types/geometries/roundrect.d.ts +2 -11
- package/dist/types/index.d.ts +3 -3
- package/dist/types/input/gamepad.d.ts +31 -31
- package/dist/types/input/keyboard.d.ts +105 -105
- package/dist/types/input/pointer.d.ts +21 -21
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
- package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
- package/dist/types/math/matrix2.d.ts +9 -63
- package/dist/types/math/matrix3.d.ts +9 -68
- package/dist/types/math/observable_vector2.d.ts +2 -2
- package/dist/types/math/observable_vector3.d.ts +2 -2
- package/dist/types/math/vector2.d.ts +8 -92
- package/dist/types/math/vector3.d.ts +8 -92
- package/dist/types/particles/settings.d.ts +29 -29
- package/dist/types/physics/body.d.ts +10 -8
- package/dist/types/physics/bounds.d.ts +24 -30
- package/dist/types/physics/collision.d.ts +12 -12
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/physics/world.d.ts +4 -7
- package/dist/types/renderable/container.d.ts +19 -19
- package/dist/types/renderable/imagelayer.d.ts +6 -6
- package/dist/types/renderable/light2d.d.ts +7 -7
- package/dist/types/renderable/renderable.d.ts +10 -18
- package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
- package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/renderable/text/glyph.d.ts +28 -0
- package/dist/types/renderable/text/text.d.ts +159 -0
- package/dist/types/renderable/text/textmetrics.d.ts +47 -0
- package/dist/types/renderable/text/textstyle.d.ts +5 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
- package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
- package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
- package/dist/types/state/stage.d.ts +3 -2
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +16 -9
- package/dist/types/system/event.d.ts +40 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +16 -43
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +4 -38
- package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
- package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
- package/dist/types/video/webgl/utils/precision.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +48 -84
- package/package.json +15 -15
- package/src/application/application.js +73 -21
- package/src/application/header.js +1 -1
- package/src/application/resize.js +11 -9
- package/src/application/settings.js +36 -0
- package/src/audio/audio.js +3 -5
- package/src/camera/camera2d.js +11 -13
- package/src/entity/entity.js +2 -3
- package/src/geometries/ellipse.js +25 -58
- package/src/geometries/line.js +17 -24
- package/src/geometries/path2d.js +15 -12
- package/src/geometries/point.js +7 -15
- package/src/geometries/poly.js +39 -96
- package/src/geometries/rectangle.js +36 -90
- package/src/geometries/roundrect.js +25 -34
- package/src/index.js +4 -4
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +3 -3
- package/src/input/pointerevent.js +5 -6
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +15 -32
- package/src/level/tiled/TMXObject.js +2 -3
- package/src/level/tiled/TMXTile.js +3 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXTileset.js +3 -6
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +36 -46
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/parser.js +3 -4
- package/src/math/color.js +4 -4
- package/src/math/matrix2.js +4 -58
- package/src/math/matrix3.js +81 -140
- package/src/math/observable_vector2.js +6 -6
- package/src/math/observable_vector3.js +4 -4
- package/src/math/vector2.js +6 -90
- package/src/math/vector3.js +5 -89
- package/src/particles/emitter.js +1 -1
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +21 -19
- package/src/physics/bounds.js +26 -32
- package/src/physics/collision.js +4 -4
- package/src/physics/detector.js +9 -9
- package/src/physics/quadtree.js +4 -4
- package/src/physics/sat.js +2 -3
- package/src/physics/world.js +5 -8
- package/src/polyfill/roundrect.js +163 -163
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +3 -3
- package/src/renderable/container.js +24 -24
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +2 -2
- package/src/renderable/nineslicesprite.js +1 -1
- package/src/renderable/renderable.js +30 -38
- package/src/renderable/sprite.js +2 -2
- package/src/{text → renderable/text}/bitmaptext.js +8 -8
- package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
- package/src/{text → renderable/text}/glyph.js +1 -1
- package/src/{text → renderable/text}/text.js +16 -17
- package/src/{text → renderable/text}/textmetrics.js +2 -2
- package/src/renderable/trigger.js +9 -9
- package/src/renderable/ui/uibaseelement.js +6 -6
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +2 -2
- package/src/state/stage.js +12 -13
- package/src/state/state.js +2 -61
- package/src/system/device.js +50 -9
- package/src/system/event.js +44 -0
- package/src/system/platform.js +18 -18
- package/src/system/pooling.js +9 -9
- package/src/tweens/tween.js +1 -1
- package/src/utils/function.js +1 -2
- package/src/video/canvas/canvas_renderer.js +4 -17
- package/src/video/renderer.js +16 -29
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +7 -28
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +12 -13
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +1 -2
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/utils/precision.js +3 -3
- package/src/video/webgl/webgl_renderer.js +61 -66
- /package/src/{text → renderable/text}/textstyle.js +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a Text Metrics object that contains helper for text manipulation
|
|
4
|
+
* @augments Bounds
|
|
5
|
+
*/
|
|
6
|
+
export default class TextMetrics extends Bounds {
|
|
7
|
+
/**
|
|
8
|
+
* @param {Text|BitmapText} ancestor - the parent object that contains this TextMetrics object
|
|
9
|
+
*/
|
|
10
|
+
constructor(ancestor: Text | BitmapText);
|
|
11
|
+
/**
|
|
12
|
+
* a reference to the parent object that contains this TextMetrics object
|
|
13
|
+
* @public
|
|
14
|
+
* @type {Renderable}
|
|
15
|
+
* @default undefined
|
|
16
|
+
*/
|
|
17
|
+
public ancestor: Renderable;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the height of a segment of inline text in CSS pixels.
|
|
20
|
+
* @returns {number} the height of a segment of inline text in CSS pixels.
|
|
21
|
+
*/
|
|
22
|
+
lineHeight(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the width of the given segment of inline text in CSS pixels.
|
|
25
|
+
* @param {string} text - the text to be measured
|
|
26
|
+
* @param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
|
|
27
|
+
* @returns {number} the width of the given segment of inline text in CSS pixels.
|
|
28
|
+
*/
|
|
29
|
+
lineWidth(text: string, context?: CanvasRenderingContext2D | undefined): number;
|
|
30
|
+
/**
|
|
31
|
+
* measure the given text size in CSS pixels
|
|
32
|
+
* @param {string} text - the text to be measured
|
|
33
|
+
* @param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
|
|
34
|
+
* @returns {TextMetrics} this
|
|
35
|
+
*/
|
|
36
|
+
measureText(text: string, context?: CanvasRenderingContext2D | undefined): TextMetrics;
|
|
37
|
+
/**
|
|
38
|
+
* wrap the given text based on the given width
|
|
39
|
+
* @param {string|string[]} text - the text to be wrapped
|
|
40
|
+
* @param {number} width - maximum width of one segment of text in css pixel
|
|
41
|
+
* @param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
|
|
42
|
+
* @returns {string[]} an array of string representing wrapped text
|
|
43
|
+
*/
|
|
44
|
+
wordWrap(text: string | string[], width: number, context?: CanvasRenderingContext2D | undefined): string[];
|
|
45
|
+
}
|
|
46
|
+
import Bounds from "../../physics/bounds.js";
|
|
47
|
+
import Text from "./text.js";
|
|
@@ -55,7 +55,6 @@ export default class UIBaseElement extends Container {
|
|
|
55
55
|
* @ignore
|
|
56
56
|
*/
|
|
57
57
|
clicked(event: any): boolean | undefined;
|
|
58
|
-
dirty: boolean | undefined;
|
|
59
58
|
/**
|
|
60
59
|
* function called when the object is pressed (to be extended)
|
|
61
60
|
* @param {Pointer} event - the event object
|
|
@@ -64,7 +64,6 @@ export default class UISpriteElement extends Sprite {
|
|
|
64
64
|
* @ignore
|
|
65
65
|
*/
|
|
66
66
|
clicked(event: any): boolean | undefined;
|
|
67
|
-
dirty: boolean | undefined;
|
|
68
67
|
/**
|
|
69
68
|
* function called when the object is pressed (to be extended)
|
|
70
69
|
* @param {Pointer} event - the event object
|
|
@@ -49,11 +49,6 @@ export default class UITextButton extends UIBaseElement {
|
|
|
49
49
|
* @type {string}
|
|
50
50
|
*/
|
|
51
51
|
bindKey: string;
|
|
52
|
-
/**
|
|
53
|
-
* The css value of a background color
|
|
54
|
-
* @type {string}
|
|
55
|
-
*/
|
|
56
|
-
backgroundColor: string;
|
|
57
52
|
/**
|
|
58
53
|
* The css value of a color to be used if the pointer hovers over the button
|
|
59
54
|
* @type {string}
|
|
@@ -85,10 +80,10 @@ export default class UITextButton extends UIBaseElement {
|
|
|
85
80
|
* @type {BitmapText}
|
|
86
81
|
*/
|
|
87
82
|
bitmapText: BitmapText;
|
|
88
|
-
dimensions: import("
|
|
83
|
+
dimensions: import("../text/textmetrics.js").default;
|
|
89
84
|
border: RoundRect;
|
|
90
85
|
draw(renderer: any): void;
|
|
91
86
|
}
|
|
92
87
|
import UIBaseElement from "./uibaseelement.js";
|
|
93
|
-
import BitmapText from "
|
|
88
|
+
import BitmapText from "../text/bitmaptext.js";
|
|
94
89
|
import RoundRect from "../../geometries/roundrect.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
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export default state;
|
|
2
2
|
declare namespace state {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
let LOADING: number;
|
|
4
|
+
let MENU: number;
|
|
5
|
+
let READY: number;
|
|
6
|
+
let PLAY: number;
|
|
7
|
+
let GAMEOVER: number;
|
|
8
|
+
let GAME_END: number;
|
|
9
|
+
let SCORE: number;
|
|
10
|
+
let CREDITS: number;
|
|
11
|
+
let SETTINGS: number;
|
|
12
|
+
let DEFAULT: number;
|
|
13
|
+
let USER: number;
|
|
14
14
|
/**
|
|
15
15
|
* Stop the current stage.
|
|
16
16
|
* @name stop
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* used by [un]watchDeviceOrientation()
|
|
3
|
+
* @ignore
|
|
3
4
|
*/
|
|
4
5
|
export function onDeviceRotate(e: any): void;
|
|
5
6
|
/**
|
|
@@ -544,6 +545,8 @@ export let alpha: number;
|
|
|
544
545
|
* Specify whether to pause the game when losing focus
|
|
545
546
|
* @name pauseOnBlur
|
|
546
547
|
* @memberof device
|
|
548
|
+
* @deprecated since 15.4.0
|
|
549
|
+
* @see Application.pauseOnBlur
|
|
547
550
|
* @type {boolean}
|
|
548
551
|
* @public
|
|
549
552
|
* @default true
|
|
@@ -553,27 +556,31 @@ export let pauseOnBlur: boolean;
|
|
|
553
556
|
* Specify whether to unpause the game when gaining focus
|
|
554
557
|
* @name resumeOnFocus
|
|
555
558
|
* @memberof device
|
|
559
|
+
* @deprecated since 15.4.0
|
|
560
|
+
* @see Application.resumeOnFocus
|
|
556
561
|
* @type {boolean}
|
|
557
562
|
* @public
|
|
558
563
|
* @default true
|
|
559
564
|
*/
|
|
560
565
|
export let resumeOnFocus: boolean;
|
|
561
|
-
/**
|
|
562
|
-
* Specify whether to automatically bring the window to the front
|
|
563
|
-
* @name autoFocus
|
|
564
|
-
* @memberof device
|
|
565
|
-
* @type {boolean}
|
|
566
|
-
* @public
|
|
567
|
-
* @default true
|
|
568
|
-
*/
|
|
569
|
-
export let autoFocus: boolean;
|
|
570
566
|
/**
|
|
571
567
|
* Specify whether to stop the game when losing focus or not.
|
|
572
568
|
* The engine restarts on focus if this is enabled.
|
|
573
569
|
* @name stopOnBlur
|
|
574
570
|
* @memberof device
|
|
571
|
+
* @deprecated since 15.4.0
|
|
572
|
+
* @see Application.stopOnBlur
|
|
575
573
|
* @type {boolean}
|
|
576
574
|
* @public
|
|
577
575
|
* @default false
|
|
578
576
|
*/
|
|
579
577
|
export let stopOnBlur: boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Specify whether to automatically bring the window to the front
|
|
580
|
+
* @name autoFocus
|
|
581
|
+
* @memberof device
|
|
582
|
+
* @type {boolean}
|
|
583
|
+
* @public
|
|
584
|
+
* @default true
|
|
585
|
+
*/
|
|
586
|
+
export let autoFocus: boolean;
|
|
@@ -63,6 +63,36 @@ 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;
|
|
76
|
+
/**
|
|
77
|
+
* event generated when the main browser or window is losing focus
|
|
78
|
+
* @public
|
|
79
|
+
* @constant
|
|
80
|
+
* @type {string}
|
|
81
|
+
* @name BLUR
|
|
82
|
+
* @memberof event
|
|
83
|
+
* @see event.on
|
|
84
|
+
*/
|
|
85
|
+
export const BLUR: string;
|
|
86
|
+
/**
|
|
87
|
+
* event generated when the main browser or window is gaining back focus
|
|
88
|
+
* @public
|
|
89
|
+
* @constant
|
|
90
|
+
* @type {string}
|
|
91
|
+
* @name FOCUS
|
|
92
|
+
* @memberof event
|
|
93
|
+
* @see event.on
|
|
94
|
+
*/
|
|
95
|
+
export const FOCUS: string;
|
|
66
96
|
/**
|
|
67
97
|
* event when the game is paused <br>
|
|
68
98
|
* Data passed : none <br>
|
|
@@ -117,6 +147,16 @@ export const STATE_RESTART: string;
|
|
|
117
147
|
* @see event.on
|
|
118
148
|
*/
|
|
119
149
|
export const STATE_CHANGE: string;
|
|
150
|
+
/**
|
|
151
|
+
* event for when a stage is resetted
|
|
152
|
+
* @public
|
|
153
|
+
* @constant
|
|
154
|
+
* @type {string}
|
|
155
|
+
* @name STAGE_RESET
|
|
156
|
+
* @memberof event
|
|
157
|
+
* @see event.on
|
|
158
|
+
*/
|
|
159
|
+
export const STAGE_RESET: string;
|
|
120
160
|
/**
|
|
121
161
|
* event for when the video is initialized<br>
|
|
122
162
|
* Data passed : none <br>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
* The device platform type
|
|
3
|
+
* @namespace platform
|
|
4
|
+
* @memberof device
|
|
5
|
+
* @property {string} ua the user agent string for the current device
|
|
6
|
+
* @property {boolean} iOS `true` if the device is an iOS platform
|
|
7
|
+
* @property {boolean} android `true` if the device is an Android platform
|
|
8
|
+
* @property {boolean} android2 `true` if the device is an Android 2.x platform
|
|
9
|
+
* @property {boolean} linux `true` if the device is a Linux platform
|
|
10
|
+
* @property {boolean} chromeOS `true` if the device is running on ChromeOS.
|
|
11
|
+
* @property {boolean} wp `true` if the device is a Windows Phone platform
|
|
12
|
+
* @property {boolean} BlackBerry`true` if the device is a BlackBerry platform
|
|
13
|
+
* @property {boolean} Kindle`true` if the device is a Kindle platform
|
|
14
|
+
* @property {boolean} ejecta `true` if running under Ejecta
|
|
15
|
+
* @property {boolean} isWeixin `true` if running under Wechat
|
|
16
|
+
* @property {boolean} nodeJS `true` if running under node.js
|
|
17
|
+
* @property {boolean} isMobile `true` if a mobile device
|
|
18
|
+
*/
|
|
19
19
|
export const ua: string;
|
|
20
20
|
export const iOS: boolean;
|
|
21
21
|
export const android: boolean;
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
export function defer(func: Function, thisArg: object, ...args: any[]): number;
|
|
21
21
|
/**
|
|
22
|
-
* returns a function that, when invoked will only be triggered at most
|
|
23
|
-
* once during a given window of time
|
|
22
|
+
* returns a function that, when invoked will only be triggered at most once during a given window of time
|
|
24
23
|
* @public
|
|
25
24
|
* @memberof utils.function
|
|
26
25
|
* @name throttle
|
|
@@ -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
|
|
@@ -43,7 +16,7 @@ export default class Renderer {
|
|
|
43
16
|
/**
|
|
44
17
|
* the requested video size ratio
|
|
45
18
|
* @public
|
|
46
|
-
* @type {
|
|
19
|
+
* @type {number}
|
|
47
20
|
*/
|
|
48
21
|
public designRatio: number;
|
|
49
22
|
/**
|
|
@@ -215,10 +188,10 @@ export default class Renderer {
|
|
|
215
188
|
clearTint(): void;
|
|
216
189
|
/**
|
|
217
190
|
* creates a Blob object representing the last rendered frame
|
|
218
|
-
* @param {
|
|
219
|
-
* @param {
|
|
220
|
-
* @param {
|
|
221
|
-
* @
|
|
191
|
+
* @param {object} [options] - An object with the following properties:
|
|
192
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
193
|
+
* @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
194
|
+
* @returns {Promise} A Promise returning a Blob object representing the last rendered frame
|
|
222
195
|
* @example
|
|
223
196
|
* renderer.convertToBlob().then((blob) => console.log(blob));
|
|
224
197
|
*/
|
|
@@ -229,10 +202,10 @@ export default class Renderer {
|
|
|
229
202
|
/**
|
|
230
203
|
* creates an ImageBitmap object of the last frame rendered
|
|
231
204
|
* (not supported by standard Canvas)
|
|
232
|
-
* @param {
|
|
233
|
-
* @param {
|
|
234
|
-
* @param {
|
|
235
|
-
* @
|
|
205
|
+
* @param {object} [options] - An object with the following properties:
|
|
206
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
207
|
+
* @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
208
|
+
* @returns {Promise} A Promise returning an ImageBitmap.
|
|
236
209
|
* @example
|
|
237
210
|
* renderer.transferToImageBitmap().then((image) => console.log(image));
|
|
238
211
|
*/
|
|
@@ -242,10 +215,10 @@ export default class Renderer {
|
|
|
242
215
|
} | undefined): Promise<any>;
|
|
243
216
|
/**
|
|
244
217
|
* returns a data URL containing a representation of the last frame rendered
|
|
245
|
-
* @param {
|
|
246
|
-
* @param {
|
|
247
|
-
* @param {
|
|
248
|
-
* @
|
|
218
|
+
* @param {object} [options] - An object with the following properties:
|
|
219
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
220
|
+
* @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
221
|
+
* @returns {Promise} A Promise returning a string containing the requested data URL.
|
|
249
222
|
* @example
|
|
250
223
|
* renderer.toDataURL().then((dataURL) => console.log(dataURL));
|
|
251
224
|
*/
|
|
@@ -38,7 +38,7 @@ declare class CanvasTexture {
|
|
|
38
38
|
clear(): void;
|
|
39
39
|
/**
|
|
40
40
|
* enable/disable image smoothing (scaling interpolation)
|
|
41
|
-
* @param {boolean} [enable=false]
|
|
41
|
+
* @param {boolean} [enable=false] - whether to enable or not image smoothing (scaling interpolation)
|
|
42
42
|
*/
|
|
43
43
|
setAntiAlias(enable?: boolean | undefined): void;
|
|
44
44
|
/**
|
|
@@ -54,15 +54,15 @@ declare class CanvasTexture {
|
|
|
54
54
|
* @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
55
55
|
* @param {number} width - The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left
|
|
56
56
|
* @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
|
|
57
|
-
* @
|
|
57
|
+
* @returns {ImageData} The ImageData extracted from this CanvasTexture.
|
|
58
58
|
*/
|
|
59
59
|
getImageData(x: number, y: number, width: number, height: number): ImageData;
|
|
60
60
|
/**
|
|
61
61
|
* creates a Blob object representing the image contained in this canvas texture
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {
|
|
65
|
-
* @
|
|
62
|
+
* @param {object} [options] - An object with the following properties:
|
|
63
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
64
|
+
* @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
65
|
+
* @returns {Promise} A Promise returning a Blob object representing the image contained in this canvas texture
|
|
66
66
|
* @example
|
|
67
67
|
* canvasTexture.convertToBlob().then((blob) => console.log(blob));
|
|
68
68
|
*/
|
|
@@ -72,10 +72,10 @@ declare class CanvasTexture {
|
|
|
72
72
|
} | undefined): Promise<any>;
|
|
73
73
|
/**
|
|
74
74
|
* creates an ImageBitmap object from the most recently rendered image of this canvas texture
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {
|
|
77
|
-
* @param {
|
|
78
|
-
* @
|
|
75
|
+
* @param {object} [options] - An object with the following properties:
|
|
76
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
77
|
+
* @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
78
|
+
* @returns {Promise} A Promise returning an ImageBitmap.
|
|
79
79
|
* @example
|
|
80
80
|
* canvasTexture.transferToImageBitmap().then((bitmap) => console.log(bitmap));
|
|
81
81
|
*/
|
|
@@ -86,10 +86,10 @@ declare class CanvasTexture {
|
|
|
86
86
|
/**
|
|
87
87
|
* returns a data URL containing a representation of the most recently rendered image of this canvas texture
|
|
88
88
|
* (not supported by OffscreenCanvas)
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
92
|
-
* @
|
|
89
|
+
* @param {object} [options] - An object with the following properties:
|
|
90
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
91
|
+
* @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
92
|
+
* @returns {Promise} A Promise returning a string containing the requested data URL.
|
|
93
93
|
* @example
|
|
94
94
|
* renderer.toDataURL().then((dataURL) => console.log(dataURL));
|
|
95
95
|
*/
|
|
@@ -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,30 +14,20 @@
|
|
|
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
|
|
55
21
|
* @param {number} width - width
|
|
56
22
|
* @param {number} height - height
|
|
57
23
|
* @param {boolean} [returnOffscreenCanvas=false] - will return an OffscreenCanvas if supported
|
|
58
|
-
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
24
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas} a new Canvas element of the given size
|
|
59
25
|
*/
|
|
60
26
|
export function createCanvas(width: number, height: number, returnOffscreenCanvas?: boolean | undefined): HTMLCanvasElement | OffscreenCanvas;
|
|
61
27
|
/**
|
|
62
28
|
* return a reference to the parent DOM element holding the main canvas
|
|
63
29
|
* @memberof video
|
|
64
|
-
* @returns {HTMLElement}
|
|
30
|
+
* @returns {HTMLElement} the HTML parent element
|
|
65
31
|
*/
|
|
66
32
|
export function getParent(): HTMLElement;
|
|
67
33
|
/**
|
|
@@ -27,12 +27,12 @@ export default class VertexArrayBuffer {
|
|
|
27
27
|
* resize the vertex buffer, retaining its original contents
|
|
28
28
|
* @ignore
|
|
29
29
|
*/
|
|
30
|
-
resize(vertexCount: any):
|
|
30
|
+
resize(vertexCount: any): this;
|
|
31
31
|
/**
|
|
32
32
|
* push a new vertex to the buffer
|
|
33
33
|
* @ignore
|
|
34
34
|
*/
|
|
35
|
-
push(x: any, y: any, u: any, v: any, tint: any):
|
|
35
|
+
push(x: any, y: any, u: any, v: any, tint: any): this;
|
|
36
36
|
/**
|
|
37
37
|
* return a reference to the data in Float32 format
|
|
38
38
|
* @ignore
|
|
@@ -5,18 +5,30 @@
|
|
|
5
5
|
export default class Compositor {
|
|
6
6
|
/**
|
|
7
7
|
* @param {WebGLRenderer} renderer - the current WebGL renderer session
|
|
8
|
-
* @param {
|
|
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
|
|
8
|
+
* @param {object} settings - additional settings to initialize this compositors
|
|
9
|
+
* @param {object[]} settings.attribute - an array of attributes definition
|
|
10
|
+
* @param {string} settings.attribute.name - name of the attribute in the vertex shader
|
|
11
|
+
* @param {number} settings.attribute.size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
12
|
+
* @param {GLenum} settings.attribute.type - data type of each component in the array
|
|
13
|
+
* @param {boolean} settings.attribute.normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
14
|
+
* @param {number} settings.attribute.offset - offset in bytes of the first component in the vertex attribute array
|
|
15
|
+
* @param {object} settings.shader - an array of attributes definition
|
|
16
|
+
* @param {string} settings.shader.vertex - a string containing the GLSL source code to set
|
|
17
|
+
* @param {string} settings.shader.fragment - a string containing the GLSL source code to set
|
|
18
18
|
*/
|
|
19
|
-
constructor(renderer: WebGLRenderer, settings:
|
|
19
|
+
constructor(renderer: WebGLRenderer, settings: {
|
|
20
|
+
attribute: {
|
|
21
|
+
name: string;
|
|
22
|
+
size: number;
|
|
23
|
+
type: GLenum;
|
|
24
|
+
normalized: boolean;
|
|
25
|
+
offset: number;
|
|
26
|
+
};
|
|
27
|
+
shader: {
|
|
28
|
+
vertex: string;
|
|
29
|
+
fragment: string;
|
|
30
|
+
};
|
|
31
|
+
});
|
|
20
32
|
/**
|
|
21
33
|
* Initialize the compositor
|
|
22
34
|
* @ignore
|
|
@@ -73,7 +85,6 @@ export default class Compositor {
|
|
|
73
85
|
*/
|
|
74
86
|
reset(): void;
|
|
75
87
|
/**
|
|
76
|
-
* @ignore
|
|
77
88
|
* called by the WebGL renderer when a compositor become the current one
|
|
78
89
|
*/
|
|
79
90
|
bind(): void;
|
|
@@ -94,7 +105,7 @@ export default class Compositor {
|
|
|
94
105
|
addAttribute(name: string, size: number, type: GLenum, normalized: boolean, offset: number): void;
|
|
95
106
|
/**
|
|
96
107
|
* set/change the current projection matrix
|
|
97
|
-
* @param {Matrix3d} matrix
|
|
108
|
+
* @param {Matrix3d} matrix - the new projection matrix
|
|
98
109
|
*/
|
|
99
110
|
setProjection(matrix: Matrix3d): void;
|
|
100
111
|
/**
|
|
@@ -17,6 +17,5 @@ export default class PrimitiveCompositor extends Compositor {
|
|
|
17
17
|
* @param {number} [vertexCount=verts.length] - amount of points defined in the points array
|
|
18
18
|
*/
|
|
19
19
|
drawVertices(mode: GLenum, verts: Point[], vertexCount?: number | undefined): void;
|
|
20
|
-
mode: any;
|
|
21
20
|
}
|
|
22
21
|
import Compositor from "./compositor.js";
|