melonjs 15.3.0 → 15.4.1
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/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 +53 -5
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +4 -8
- package/dist/melonjs.mjs/application/settings.js +5 -5
- 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 +26 -29
- 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 +2 -2
- 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 +26 -26
- 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 +2 -2
- package/dist/melonjs.mjs/state/state.js +1 -38
- package/dist/melonjs.mjs/system/device.js +49 -10
- 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 +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 +3 -7
- package/dist/melonjs.mjs/video/renderer.js +16 -16
- 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 +4 -4
- 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 +50 -52
- package/dist/melonjs.module.js +1137 -1576
- package/dist/types/application/application.d.ts +28 -4
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +23 -23
- package/dist/types/audio/audio.d.ts +3 -5
- 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/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 +9 -16
- 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/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +15 -9
- package/dist/types/system/event.d.ts +20 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/renderer.d.ts +13 -13
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +2 -2
- 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 +47 -50
- package/package.json +15 -15
- package/src/application/application.js +51 -3
- package/src/application/header.js +1 -1
- package/src/application/resize.js +3 -7
- package/src/application/settings.js +4 -4
- 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 +25 -28
- 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 +1 -1
- 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 +25 -25
- 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 +1 -1
- package/src/state/state.js +0 -49
- package/src/system/device.js +48 -9
- package/src/system/event.js +22 -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 +2 -6
- package/src/video/renderer.js +15 -15
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +3 -3
- 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 +49 -51
- /package/src/{text → renderable/text}/textstyle.js +0 -0
package/src/system/event.js
CHANGED
|
@@ -41,6 +41,28 @@ export const BOOT = "me.boot";
|
|
|
41
41
|
*/
|
|
42
42
|
export const TICK = "me.tick";
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* event generated when the main browser or window is losing focus
|
|
46
|
+
* @public
|
|
47
|
+
* @constant
|
|
48
|
+
* @type {string}
|
|
49
|
+
* @name BLUR
|
|
50
|
+
* @memberof event
|
|
51
|
+
* @see event.on
|
|
52
|
+
*/
|
|
53
|
+
export const BLUR = "me.blur";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* event generated when the main browser or window is gaining back focus
|
|
57
|
+
* @public
|
|
58
|
+
* @constant
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @name FOCUS
|
|
61
|
+
* @memberof event
|
|
62
|
+
* @see event.on
|
|
63
|
+
*/
|
|
64
|
+
export const FOCUS = "me.focus";
|
|
65
|
+
|
|
44
66
|
/**
|
|
45
67
|
* event when the game is paused <br>
|
|
46
68
|
* Data passed : none <br>
|
package/src/system/platform.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
/**
|
|
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
|
|
|
20
20
|
export const ua = typeof globalThis.navigator !== "undefined" ? globalThis.navigator.userAgent : "";
|
|
21
21
|
export const iOS = /iPhone|iPad|iPod/i.test(ua);
|
package/src/system/pooling.js
CHANGED
|
@@ -38,15 +38,15 @@ class ObjectPool {
|
|
|
38
38
|
* me.pool.register("cherrysprite", Cherry, true);
|
|
39
39
|
*/
|
|
40
40
|
register(className, classObj, recycling = false) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
if (typeof (classObj) !== "undefined") {
|
|
42
|
+
this.objectClass[className] = {
|
|
43
|
+
"class" : classObj,
|
|
44
|
+
"pool" : (recycling ? [] : undefined)
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error("Cannot register object '" + className + "', invalid class");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Pull a new instance of the requested object (if added into the object pool)
|
package/src/tweens/tween.js
CHANGED
|
@@ -23,7 +23,7 @@ import { Interpolation } from "./interpolation.js";
|
|
|
23
23
|
* author lechecacharro<br>
|
|
24
24
|
* author Josh Faul / http://jocafa.com/
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
export default class Tween {
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {object} object - object on which to apply the tween
|
package/src/utils/function.js
CHANGED
|
@@ -23,8 +23,7 @@ export function defer(func, thisArg, ...args) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* returns a function that, when invoked will only be triggered at most
|
|
27
|
-
* once during a given window of time
|
|
26
|
+
* returns a function that, when invoked will only be triggered at most once during a given window of time
|
|
28
27
|
* @public
|
|
29
28
|
* @memberof utils.function
|
|
30
29
|
* @name throttle
|
|
@@ -12,7 +12,7 @@ import * as event from "./../../system/event.js";
|
|
|
12
12
|
* a canvas renderer object
|
|
13
13
|
* @augments Renderer
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
export default class CanvasRenderer extends Renderer {
|
|
16
16
|
/**
|
|
17
17
|
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
18
18
|
*/
|
|
@@ -527,11 +527,7 @@ import * as event from "./../../system/event.js";
|
|
|
527
527
|
setColor(color) {
|
|
528
528
|
let context = this.getContext();
|
|
529
529
|
context.strokeStyle =
|
|
530
|
-
context.fillStyle = (
|
|
531
|
-
color instanceof Color ?
|
|
532
|
-
color.toRGBA() :
|
|
533
|
-
color
|
|
534
|
-
);
|
|
530
|
+
context.fillStyle = (color instanceof Color ? color.toRGBA() : color);
|
|
535
531
|
}
|
|
536
532
|
|
|
537
533
|
/**
|
package/src/video/renderer.js
CHANGED
|
@@ -18,7 +18,7 @@ import Point from "../geometries/point.js";
|
|
|
18
18
|
* @classdesc
|
|
19
19
|
* a base renderer object
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
export default class Renderer {
|
|
22
22
|
/**
|
|
23
23
|
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
24
24
|
*/
|
|
@@ -33,7 +33,7 @@ import Point from "../geometries/point.js";
|
|
|
33
33
|
/**
|
|
34
34
|
* the requested video size ratio
|
|
35
35
|
* @public
|
|
36
|
-
* @type {
|
|
36
|
+
* @type {number}
|
|
37
37
|
*/
|
|
38
38
|
this.designRatio = this.settings.width / this.settings.height;
|
|
39
39
|
|
|
@@ -190,7 +190,7 @@ import Point from "../geometries/point.js";
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
let _context = canvas.getContext("2d", {
|
|
193
|
-
|
|
193
|
+
"alpha" : transparent
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
if (!_context.canvas) {
|
|
@@ -406,10 +406,10 @@ import Point from "../geometries/point.js";
|
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
408
|
* creates a Blob object representing the last rendered frame
|
|
409
|
-
* @param {
|
|
410
|
-
* @param {
|
|
411
|
-
* @param {
|
|
412
|
-
* @
|
|
409
|
+
* @param {object} [options] - An object with the following properties:
|
|
410
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
411
|
+
* @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.
|
|
412
|
+
* @returns {Promise} A Promise returning a Blob object representing the last rendered frame
|
|
413
413
|
* @example
|
|
414
414
|
* renderer.convertToBlob().then((blob) => console.log(blob));
|
|
415
415
|
*/
|
|
@@ -426,10 +426,10 @@ import Point from "../geometries/point.js";
|
|
|
426
426
|
/**
|
|
427
427
|
* creates an ImageBitmap object of the last frame rendered
|
|
428
428
|
* (not supported by standard Canvas)
|
|
429
|
-
* @param {
|
|
430
|
-
* @param {
|
|
431
|
-
* @param {
|
|
432
|
-
* @
|
|
429
|
+
* @param {object} [options] - An object with the following properties:
|
|
430
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
431
|
+
* @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.
|
|
432
|
+
* @returns {Promise} A Promise returning an ImageBitmap.
|
|
433
433
|
* @example
|
|
434
434
|
* renderer.transferToImageBitmap().then((image) => console.log(image));
|
|
435
435
|
*/
|
|
@@ -447,10 +447,10 @@ import Point from "../geometries/point.js";
|
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
449
|
* returns a data URL containing a representation of the last frame rendered
|
|
450
|
-
* @param {
|
|
451
|
-
* @param {
|
|
452
|
-
* @param {
|
|
453
|
-
* @
|
|
450
|
+
* @param {object} [options] - An object with the following properties:
|
|
451
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
452
|
+
* @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.
|
|
453
|
+
* @returns {Promise} A Promise returning a string containing the requested data URL.
|
|
454
454
|
* @example
|
|
455
455
|
* renderer.toDataURL().then((dataURL) => console.log(dataURL));
|
|
456
456
|
*/
|
|
@@ -10,18 +10,18 @@ import { ETA } from "./../../math/math.js";
|
|
|
10
10
|
* @ignore
|
|
11
11
|
*/
|
|
12
12
|
export function createAtlas(width, height, name = "default", repeat = "no-repeat") {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
return {
|
|
14
|
+
"meta" : {
|
|
15
|
+
"app" : "melonJS",
|
|
16
|
+
"size" : { "w" : width, "h" : height },
|
|
17
|
+
"repeat" : repeat,
|
|
18
|
+
"image" : "default"
|
|
19
|
+
},
|
|
20
|
+
"frames" : [{
|
|
21
|
+
"filename" : name,
|
|
22
|
+
"frame" : { "x" : 0, "y" : 0, "w" : width, "h" : height }
|
|
23
|
+
}]
|
|
24
|
+
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -62,7 +62,7 @@ class CanvasTexture {
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* enable/disable image smoothing (scaling interpolation)
|
|
65
|
-
* @param {boolean} [enable=false]
|
|
65
|
+
* @param {boolean} [enable=false] - whether to enable or not image smoothing (scaling interpolation)
|
|
66
66
|
*/
|
|
67
67
|
setAntiAlias(enable = false) {
|
|
68
68
|
let canvas = this.canvas;
|
|
@@ -105,7 +105,7 @@ class CanvasTexture {
|
|
|
105
105
|
* @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
106
106
|
* @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
|
|
107
107
|
* @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
|
|
108
|
-
* @
|
|
108
|
+
* @returns {ImageData} The ImageData extracted from this CanvasTexture.
|
|
109
109
|
*/
|
|
110
110
|
getImageData(x, y, width, height) {
|
|
111
111
|
// clamp values
|
|
@@ -119,10 +119,10 @@ class CanvasTexture {
|
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* creates a Blob object representing the image contained in this canvas texture
|
|
122
|
-
* @param {
|
|
123
|
-
* @param {
|
|
124
|
-
* @param {
|
|
125
|
-
* @
|
|
122
|
+
* @param {object} [options] - An object with the following properties:
|
|
123
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
124
|
+
* @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.
|
|
125
|
+
* @returns {Promise} A Promise returning a Blob object representing the image contained in this canvas texture
|
|
126
126
|
* @example
|
|
127
127
|
* canvasTexture.convertToBlob().then((blob) => console.log(blob));
|
|
128
128
|
*/
|
|
@@ -140,10 +140,10 @@ class CanvasTexture {
|
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
142
|
* creates an ImageBitmap object from the most recently rendered image of this canvas texture
|
|
143
|
-
* @param {
|
|
144
|
-
* @param {
|
|
145
|
-
* @param {
|
|
146
|
-
* @
|
|
143
|
+
* @param {object} [options] - An object with the following properties:
|
|
144
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
145
|
+
* @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.
|
|
146
|
+
* @returns {Promise} A Promise returning an ImageBitmap.
|
|
147
147
|
* @example
|
|
148
148
|
* canvasTexture.transferToImageBitmap().then((bitmap) => console.log(bitmap));
|
|
149
149
|
*/
|
|
@@ -164,10 +164,10 @@ class CanvasTexture {
|
|
|
164
164
|
/**
|
|
165
165
|
* returns a data URL containing a representation of the most recently rendered image of this canvas texture
|
|
166
166
|
* (not supported by OffscreenCanvas)
|
|
167
|
-
* @param {
|
|
168
|
-
* @param {
|
|
169
|
-
* @param {
|
|
170
|
-
* @
|
|
167
|
+
* @param {object} [options] - An object with the following properties:
|
|
168
|
+
* @param {string} [options.type="image/png"] - A string indicating the image format
|
|
169
|
+
* @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.
|
|
170
|
+
* @returns {Promise} A Promise returning a string containing the requested data URL.
|
|
171
171
|
* @example
|
|
172
172
|
* renderer.toDataURL().then((dataURL) => console.log(dataURL));
|
|
173
173
|
*/
|
package/src/video/video.js
CHANGED
|
@@ -61,7 +61,7 @@ export function init(width, height, options) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
|
-
|
|
64
|
+
// initialize the default game Application with the given options
|
|
65
65
|
game.init(width, height, options);
|
|
66
66
|
} catch (e) {
|
|
67
67
|
console.log(e.message);
|
|
@@ -123,7 +123,7 @@ export function init(width, height, options) {
|
|
|
123
123
|
* @param {number} width - width
|
|
124
124
|
* @param {number} height - height
|
|
125
125
|
* @param {boolean} [returnOffscreenCanvas=false] - will return an OffscreenCanvas if supported
|
|
126
|
-
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
126
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas} a new Canvas element of the given size
|
|
127
127
|
*/
|
|
128
128
|
export function createCanvas(width, height, returnOffscreenCanvas = false) {
|
|
129
129
|
let _canvas;
|
|
@@ -152,7 +152,7 @@ export function createCanvas(width, height, returnOffscreenCanvas = false) {
|
|
|
152
152
|
/**
|
|
153
153
|
* return a reference to the parent DOM element holding the main canvas
|
|
154
154
|
* @memberof video
|
|
155
|
-
* @returns {HTMLElement}
|
|
155
|
+
* @returns {HTMLElement} the HTML parent element
|
|
156
156
|
*/
|
|
157
157
|
export function getParent() {
|
|
158
158
|
return game.getParentElement();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @ignore
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default class VertexArrayBuffer {
|
|
9
9
|
|
|
10
10
|
constructor(vertex_size, vertex_per_obj) {
|
|
11
11
|
// the size of one vertex in float
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* @ignore
|
|
39
39
|
*/
|
|
40
40
|
isFull(vertex = this.objSize) {
|
|
41
|
-
|
|
41
|
+
return (this.vertexCount + vertex >= this.maxVertex);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -5,19 +5,19 @@ import GLShader from "../glshader.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* A base Compositor object.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
export default class Compositor {
|
|
9
9
|
/**
|
|
10
10
|
* @param {WebGLRenderer} renderer - the current WebGL renderer session
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {object[]} attribute - an array of attributes definition
|
|
13
|
-
* @param {string} attribute.name - name of the attribute in the vertex shader
|
|
14
|
-
* @param {number} attribute.size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
15
|
-
* @param {GLenum} attribute.type - data type of each component in the array
|
|
16
|
-
* @param {boolean} attribute.normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
17
|
-
* @param {number} attribute.offset - offset in bytes of the first component in the vertex attribute array
|
|
18
|
-
* @param {object} shader - an array of attributes definition
|
|
19
|
-
* @param {string} shader.vertex - a string containing the GLSL source code to set
|
|
20
|
-
* @param {string} shader.fragment - a string containing the GLSL source code to set
|
|
11
|
+
* @param {object} settings - additional settings to initialize this compositors
|
|
12
|
+
* @param {object[]} settings.attribute - an array of attributes definition
|
|
13
|
+
* @param {string} settings.attribute.name - name of the attribute in the vertex shader
|
|
14
|
+
* @param {number} settings.attribute.size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
15
|
+
* @param {GLenum} settings.attribute.type - data type of each component in the array
|
|
16
|
+
* @param {boolean} settings.attribute.normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
17
|
+
* @param {number} settings.attribute.offset - offset in bytes of the first component in the vertex attribute array
|
|
18
|
+
* @param {object} settings.shader - an array of attributes definition
|
|
19
|
+
* @param {string} settings.shader.vertex - a string containing the GLSL source code to set
|
|
20
|
+
* @param {string} settings.shader.fragment - a string containing the GLSL source code to set
|
|
21
21
|
*/
|
|
22
22
|
constructor (renderer, settings) {
|
|
23
23
|
this.init(renderer, settings);
|
|
@@ -119,7 +119,6 @@ import GLShader from "../glshader.js";
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* @ignore
|
|
123
122
|
* called by the WebGL renderer when a compositor become the current one
|
|
124
123
|
*/
|
|
125
124
|
bind() {
|
|
@@ -192,7 +191,7 @@ import GLShader from "../glshader.js";
|
|
|
192
191
|
|
|
193
192
|
/**
|
|
194
193
|
* set/change the current projection matrix
|
|
195
|
-
* @param {Matrix3d} matrix
|
|
194
|
+
* @param {Matrix3d} matrix - the new projection matrix
|
|
196
195
|
*/
|
|
197
196
|
setProjection(matrix) {
|
|
198
197
|
this.currentShader.setUniform("uProjectionMatrix", matrix);
|
|
@@ -8,7 +8,7 @@ import Compositor from "./compositor.js";
|
|
|
8
8
|
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
9
9
|
* @augments Compositor
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default class PrimitiveCompositor extends Compositor {
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Initialize the compositor
|
|
@@ -35,8 +35,8 @@ import Compositor from "./compositor.js";
|
|
|
35
35
|
drawVertices(mode, verts, vertexCount = verts.length) {
|
|
36
36
|
let viewMatrix = this.viewMatrix;
|
|
37
37
|
let vertexData = this.vertexData;
|
|
38
|
-
let color = this.renderer.currentColor;
|
|
39
38
|
let alpha = this.renderer.getGlobalAlpha();
|
|
39
|
+
let colorUint32 = this.renderer.currentColor.toUint32(alpha);
|
|
40
40
|
|
|
41
41
|
if (vertexData.isFull(vertexCount)) {
|
|
42
42
|
// is the vertex buffer full if we add more vertices
|
|
@@ -52,11 +52,11 @@ import Compositor from "./compositor.js";
|
|
|
52
52
|
if (!viewMatrix.isIdentity()) {
|
|
53
53
|
verts.forEach((vert) => {
|
|
54
54
|
viewMatrix.apply(vert);
|
|
55
|
-
vertexData.push(vert.x, vert.y, undefined, undefined,
|
|
55
|
+
vertexData.push(vert.x, vert.y, undefined, undefined, colorUint32);
|
|
56
56
|
});
|
|
57
57
|
} else {
|
|
58
58
|
verts.forEach((vert) => {
|
|
59
|
-
vertexData.push(vert.x, vert.y, undefined, undefined,
|
|
59
|
+
vertexData.push(vert.x, vert.y, undefined, undefined, colorUint32);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -18,7 +18,7 @@ let V_ARRAY = [
|
|
|
18
18
|
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
19
19
|
* @augments Compositor
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
export default class QuadCompositor extends Compositor {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Initialize the compositor
|
|
@@ -108,7 +108,6 @@ let V_ARRAY = [
|
|
|
108
108
|
/**
|
|
109
109
|
* delete the given WebGL texture
|
|
110
110
|
* @param {WebGLTexture} [texture] - a WebGL texture to delete
|
|
111
|
-
* @param {number} [unit] - Texture unit to delete
|
|
112
111
|
*/
|
|
113
112
|
deleteTexture2D(texture) {
|
|
114
113
|
this.gl.deleteTexture(texture);
|
|
@@ -9,7 +9,7 @@ import { minify } from "./utils/string.js";
|
|
|
9
9
|
* @classdesc
|
|
10
10
|
* a base GL Shader object
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export default class GLShader {
|
|
13
13
|
/**
|
|
14
14
|
* @param {WebGLRenderingContext} gl - the current WebGL rendering context
|
|
15
15
|
* @param {string} vertex - a string containing the GLSL source code to set
|
|
@@ -13,17 +13,17 @@ export function setPrecision(src, precision) {
|
|
|
13
13
|
/**
|
|
14
14
|
* return the highest precision format supported by this device for GL Shaders
|
|
15
15
|
* @ignore
|
|
16
|
-
* @param {WebGLRenderingContext} gl
|
|
16
|
+
* @param {WebGLRenderingContext} gl - the current WebGL context
|
|
17
17
|
* @returns {boolean} "lowp", "mediump", or "highp"
|
|
18
18
|
*/
|
|
19
19
|
export function getMaxShaderPrecision(gl) {
|
|
20
20
|
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
|
|
21
21
|
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0) {
|
|
22
|
-
|
|
22
|
+
return "highp";
|
|
23
23
|
}
|
|
24
24
|
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
|
|
25
25
|
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0) {
|
|
26
|
-
|
|
26
|
+
return "mediump";
|
|
27
27
|
}
|
|
28
28
|
return "lowp";
|
|
29
29
|
}
|