melonjs 14.1.2 → 14.2.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 +3 -4
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +7 -3
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +1 -1
- package/dist/melonjs.mjs/_virtual/index2.js +7 -3
- package/dist/melonjs.mjs/_virtual/make-built-in.js +10 -0
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/object-define-property.js +10 -0
- package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +10 -0
- package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +10 -0
- package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +10 -0
- package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +10 -0
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/shared.js +10 -0
- package/dist/melonjs.mjs/application/application.js +21 -14
- package/dist/melonjs.mjs/application/resize.js +119 -0
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +1 -1
- package/dist/melonjs.mjs/game.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 +3 -3
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +3 -3
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +3 -34
- 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 +6 -7
- 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 +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/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/math/color.js +1 -1
- 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/src/arraymultimap.js +3 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +3 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +3 -2
- package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-end.js +13 -0
- package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-start.js +13 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/a-callable.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/an-object.js +21 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/array-includes.js +45 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/classof-raw.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/classof.js +43 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/copy-constructor-properties.js +32 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/create-non-enumerable-property.js +24 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/create-property-descriptor.js +17 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/define-built-in.js +43 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/define-global-property.js +23 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/descriptors.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/document-all.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/document-create-element.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/engine-user-agent.js +14 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/engine-v8-version.js +39 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/entry-unbind.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/enum-bug-keys.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/export.js +72 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/fails.js +16 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-bind-native.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-call.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-name.js +29 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-uncurry-this.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/get-built-in.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/get-method.js +21 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/global.js +25 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/has-own-property.js +23 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/hidden-keys.js +10 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/ie8-dom-define.js +24 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/indexed-object.js +28 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/inspect-source.js +27 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/internal-state.js +88 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-callable.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-forced.js +34 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-null-or-undefined.js +14 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-object.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-symbol.js +27 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/length-of-array-like.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/make-built-in.js +68 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/math-trunc.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-define-property.js +58 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-descriptor.js +41 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-names.js +23 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-symbols.js +12 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-is-prototype-of.js +14 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-keys-internal.js +35 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-property-is-enumerable.js +23 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/ordinary-to-primitive.js +28 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/own-keys.js +31 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/require-object-coercible.js +21 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared-key.js +21 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared-store.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared.js +24 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-end.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-forced.js +28 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-start.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim.js +45 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/symbol-constructor-detection.js +26 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-absolute-index.js +23 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-indexed-object.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-integer-or-infinity.js +20 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-length.js +20 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-object.js +20 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-primitive.js +41 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-property-key.js +21 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-string-tag-support.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-string.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/try-to-string.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/uid.js +20 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/use-symbol-as-uid.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/v8-prototype-define-bug.js +24 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/weak-map-basic-detection.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/well-known-symbol.js +41 -0
- package/dist/melonjs.mjs/node_modules/core-js/internals/whitespaces.js +12 -0
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.global-this.js +18 -0
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-end.js +22 -0
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-left.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-right.js +19 -0
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-start.js +22 -0
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +4 -5
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +3 -3
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.mjs.js +9 -0
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +5 -2
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3 -2
- 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 +4 -4
- package/dist/melonjs.mjs/polyfill/console.js +18 -0
- package/dist/melonjs.mjs/polyfill/performance.js +27 -0
- package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +46 -0
- package/dist/melonjs.mjs/polyfill/roundrect.js +242 -0
- 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/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/re_container.js +1016 -0
- package/dist/melonjs.mjs/renderable/renderable.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/state/state.js +1 -1
- package/dist/melonjs.mjs/system/device.js +8 -8
- package/dist/melonjs.mjs/system/dom.js +3 -2
- package/dist/melonjs.mjs/system/event.js +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +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 +4 -29
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
- package/dist/melonjs.mjs/video/renderer.js +19 -6
- 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 +20 -1
- package/dist/melonjs.mjs/video/utils/resize.js +116 -0
- package/dist/melonjs.mjs/video/video.js +20 -162
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.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_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1 -1
- package/dist/melonjs.module.js +23849 -22258
- package/package.json +13 -13
- package/src/application/application.js +20 -13
- package/src/input/pointerevent.js +5 -6
- package/src/plugin/plugin.js +1 -1
- package/src/system/device.js +7 -7
- package/src/system/dom.js +2 -1
- package/src/utils/utils.js +3 -28
- package/src/video/renderer.js +20 -7
- package/src/video/texture/canvas_texture.js +19 -0
- package/src/video/utils/resize.js +107 -0
- package/src/video/video.js +17 -159
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.2.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -469,7 +469,7 @@ function enableSwipe(enable) {
|
|
|
469
469
|
*/
|
|
470
470
|
function isFullscreen() {
|
|
471
471
|
if (hasFullscreenSupport) {
|
|
472
|
-
return !!(prefixed("fullscreenElement", document) || document.mozFullScreenElement);
|
|
472
|
+
return !!(prefixed("fullscreenElement", globalThis.document) || globalThis.document.mozFullScreenElement);
|
|
473
473
|
} else {
|
|
474
474
|
return false;
|
|
475
475
|
}
|
|
@@ -480,7 +480,7 @@ function isFullscreen() {
|
|
|
480
480
|
* @function requestFullscreen
|
|
481
481
|
* @memberof device
|
|
482
482
|
* @public
|
|
483
|
-
* @param {
|
|
483
|
+
* @param {Element} [element] - the element to be set in full-screen mode.
|
|
484
484
|
* @example
|
|
485
485
|
* // add a keyboard shortcut to toggle Fullscreen mode on/off
|
|
486
486
|
* me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
|
|
@@ -509,7 +509,7 @@ function requestFullscreen(element) {
|
|
|
509
509
|
*/
|
|
510
510
|
function exitFullscreen() {
|
|
511
511
|
if (hasFullscreenSupport && isFullscreen()) {
|
|
512
|
-
document.exitFullscreen();
|
|
512
|
+
globalThis.document.exitFullscreen();
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
|
|
@@ -662,7 +662,7 @@ function getElement(element) {
|
|
|
662
662
|
|
|
663
663
|
if (element !== "undefined") {
|
|
664
664
|
if (typeof element === "string") {
|
|
665
|
-
target = document.getElementById(element);
|
|
665
|
+
target = globalThis.document.getElementById(element);
|
|
666
666
|
} else if (typeof element === "object" && element.nodeType === Node.ELEMENT_NODE) {
|
|
667
667
|
target = element;
|
|
668
668
|
}
|
|
@@ -671,7 +671,7 @@ function getElement(element) {
|
|
|
671
671
|
// fallback, if invalid target or non HTMLElement object
|
|
672
672
|
if (!target) {
|
|
673
673
|
//default to document.body
|
|
674
|
-
target = document.body;
|
|
674
|
+
target = globalThis.document.body;
|
|
675
675
|
}
|
|
676
676
|
|
|
677
677
|
return target;
|
|
@@ -688,7 +688,7 @@ function getElement(element) {
|
|
|
688
688
|
* @returns {DOMRect} the size and position of the element relatively to the viewport
|
|
689
689
|
*/
|
|
690
690
|
function getElementBounds(element) {
|
|
691
|
-
if (typeof element === "object" && element !== document.body && typeof element.getBoundingClientRect !== "undefined") {
|
|
691
|
+
if (typeof element === "object" && element !== globalThis.document.body && typeof element.getBoundingClientRect !== "undefined") {
|
|
692
692
|
return element.getBoundingClientRect();
|
|
693
693
|
} else {
|
|
694
694
|
domRect.width = domRect.right = globalThis.innerWidth;
|
|
@@ -723,7 +723,7 @@ function getParentBounds(element) {
|
|
|
723
723
|
function isWebGLSupported(options) {
|
|
724
724
|
let _supported = false;
|
|
725
725
|
try {
|
|
726
|
-
let canvas = document.createElement("canvas");
|
|
726
|
+
let canvas = globalThis.document.createElement("canvas");
|
|
727
727
|
let ctxOptions = {
|
|
728
728
|
stencil: true,
|
|
729
729
|
failIfMajorPerformanceCaveat: options.failIfMajorPerformanceCaveat
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.2.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
6
6
|
* @copyright (C) 2011 - 2022 Olivier Biot (AltByte Pte Ltd)
|
|
7
7
|
*/
|
|
8
8
|
import { once, DOM_READY, emit } from './event.js';
|
|
9
|
+
import { nodeJS } from './platform.js';
|
|
9
10
|
|
|
10
11
|
// track if DOMContentLoaded was called already
|
|
11
12
|
let readyBound = false;
|
|
@@ -58,7 +59,7 @@ function DOMContentLoaded(fn) {
|
|
|
58
59
|
// bind dom load event if not done yet
|
|
59
60
|
if (!readyBound) {
|
|
60
61
|
// directly call domReady if document is already "ready"
|
|
61
|
-
if (
|
|
62
|
+
if (nodeJS === true || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
|
|
62
63
|
// defer the fn call to ensure our script is fully loaded
|
|
63
64
|
globalThis.setTimeout(_domReady, 0);
|
|
64
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.2.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -11,9 +11,6 @@ import * as file from './file.js';
|
|
|
11
11
|
import * as string from './string.js';
|
|
12
12
|
import { toHex } from './string.js';
|
|
13
13
|
import * as _function from './function.js';
|
|
14
|
-
import { createCanvas } from '../video/video.js';
|
|
15
|
-
import CanvasRenderer from '../video/canvas/canvas_renderer.js';
|
|
16
|
-
import { version } from '../index.js';
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* a collection of utility functions
|
|
@@ -32,35 +29,13 @@ var utils = {
|
|
|
32
29
|
string : string,
|
|
33
30
|
function : _function,
|
|
34
31
|
|
|
35
|
-
/**
|
|
36
|
-
* Get image pixels
|
|
37
|
-
* @public
|
|
38
|
-
* @memberof utils
|
|
39
|
-
* @name getPixels
|
|
40
|
-
* @param {HTMLImageElement|HTMLCanvasElement} image - Image to read
|
|
41
|
-
* @returns {ImageData} ImageData object
|
|
42
|
-
*/
|
|
43
|
-
getPixels : function (image) {
|
|
44
|
-
if (image instanceof HTMLImageElement) {
|
|
45
|
-
var _context = CanvasRenderer.getContext2d(
|
|
46
|
-
createCanvas(image.width, image.height)
|
|
47
|
-
);
|
|
48
|
-
_context.drawImage(image, 0, 0);
|
|
49
|
-
return _context.getImageData(0, 0, image.width, image.height);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// canvas !
|
|
53
|
-
return image.getContext("2d").getImageData(0, 0, image.width, image.height);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
32
|
/**
|
|
58
33
|
* Compare two version strings
|
|
59
34
|
* @public
|
|
60
35
|
* @memberof utils
|
|
61
36
|
* @name checkVersion
|
|
62
|
-
* @param {string} first -
|
|
63
|
-
* @param {string}
|
|
37
|
+
* @param {string} first - Ffrst version string to compare
|
|
38
|
+
* @param {string} second - second version string to compare
|
|
64
39
|
* @returns {number} comparison result <br>< 0 : first < second<br>
|
|
65
40
|
* 0 : first == second<br>
|
|
66
41
|
* > 0 : first > second
|
|
@@ -71,7 +46,7 @@ var utils = {
|
|
|
71
46
|
* );
|
|
72
47
|
* }
|
|
73
48
|
*/
|
|
74
|
-
checkVersion : function (first, second
|
|
49
|
+
checkVersion : function (first, second) {
|
|
75
50
|
var a = first.split(".");
|
|
76
51
|
var b = second.split(".");
|
|
77
52
|
var len = Math.min(a.length, b.length);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.2.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import Color from '../math/color.js';
|
|
9
9
|
import Matrix3d from '../math/matrix3.js';
|
|
10
|
-
import { createCanvas
|
|
10
|
+
import { createCanvas } from './video.js';
|
|
11
11
|
import { on, emit, GAME_RESET, CANVAS_ONRESIZE } from '../system/event.js';
|
|
12
12
|
import { platform } from '../system/device.js';
|
|
13
13
|
import { setPrefixed } from '../utils/agent.js';
|
|
@@ -18,6 +18,7 @@ import Polygon from '../geometries/poly.js';
|
|
|
18
18
|
import Line from '../geometries/line.js';
|
|
19
19
|
import Bounds from '../physics/bounds.js';
|
|
20
20
|
import Path2D from '../geometries/path2d.js';
|
|
21
|
+
import Vector2d from '../math/vector2.js';
|
|
21
22
|
import Point from '../geometries/point.js';
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -48,6 +49,20 @@ import Point from '../geometries/point.js';
|
|
|
48
49
|
*/
|
|
49
50
|
this.settings = options;
|
|
50
51
|
|
|
52
|
+
/**
|
|
53
|
+
* the requested video size ratio
|
|
54
|
+
* @public
|
|
55
|
+
* @type {Number}
|
|
56
|
+
*/
|
|
57
|
+
this.designRatio = this.settings.width / this.settings.height;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* the scaling ratio to be applied to the main canvas
|
|
61
|
+
* @type {Vector2d}
|
|
62
|
+
* @default <1,1>
|
|
63
|
+
*/
|
|
64
|
+
this.scaleRatio = new Vector2d(this.settings.scale, this.settings.scale);
|
|
65
|
+
|
|
51
66
|
/**
|
|
52
67
|
* true if the current rendering context is valid
|
|
53
68
|
* @default true
|
|
@@ -101,9 +116,9 @@ import Point from '../geometries/point.js';
|
|
|
101
116
|
// default uvOffset
|
|
102
117
|
this.uvOffset = 0;
|
|
103
118
|
|
|
104
|
-
// reset the
|
|
119
|
+
// reset the renderer on game reset
|
|
105
120
|
on(GAME_RESET, () => {
|
|
106
|
-
|
|
121
|
+
this.reset();
|
|
107
122
|
});
|
|
108
123
|
}
|
|
109
124
|
|
|
@@ -330,8 +345,6 @@ import Point from '../geometries/point.js';
|
|
|
330
345
|
|
|
331
346
|
/**
|
|
332
347
|
* fill the given shape
|
|
333
|
-
* @name fill
|
|
334
|
-
* @memberof Renderer
|
|
335
348
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to fill
|
|
336
349
|
*/
|
|
337
350
|
fill(shape) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.2.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { createCanvas } from '../video.js';
|
|
9
9
|
import { setPrefixed } from '../../utils/agent.js';
|
|
10
|
+
import { clamp } from '../../math/math.js';
|
|
10
11
|
|
|
11
12
|
// default canvas settings
|
|
12
13
|
var defaultAttributes = {
|
|
@@ -104,6 +105,24 @@ class CanvasTexture {
|
|
|
104
105
|
this.canvas.height = Math.round(height);
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Returns an ImageData object representing the underlying pixel data for a specified portion of this canvas texture
|
|
110
|
+
* @param {number} x - The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
111
|
+
* @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
112
|
+
* @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
|
|
113
|
+
* @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
|
|
114
|
+
* @return {ImageData} The ImageData extracted from this CanvasTexture.
|
|
115
|
+
*/
|
|
116
|
+
getImageData(x, y, width, height) {
|
|
117
|
+
// clamp values
|
|
118
|
+
x = clamp(Math.floor(x), 0, this.canvas.width - 1);
|
|
119
|
+
y = clamp(Math.floor(y), 0, this.canvas.height - 1);
|
|
120
|
+
width = clamp(width, 1, this.canvas.width - x);
|
|
121
|
+
height = clamp(height, 1, this.canvas.height - y);
|
|
122
|
+
// return imageData
|
|
123
|
+
return this.context.getImageData(x, y, width, height);
|
|
124
|
+
}
|
|
125
|
+
|
|
107
126
|
/**
|
|
108
127
|
* @ignore
|
|
109
128
|
*/
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* melonJS Game Engine - v14.2.0
|
|
3
|
+
* http://www.melonjs.org
|
|
4
|
+
* melonjs is licensed under the MIT License.
|
|
5
|
+
* http://www.opensource.org/licenses/mit-license
|
|
6
|
+
* @copyright (C) 2011 - 2022 Olivier Biot (AltByte Pte Ltd)
|
|
7
|
+
*/
|
|
8
|
+
import { getParentBounds, devicePixelRatio } from '../../system/device.js';
|
|
9
|
+
import game from '../../game.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* scale the "displayed" canvas by the given scalar.
|
|
13
|
+
* this will modify the size of canvas element directly.
|
|
14
|
+
* Only use this if you are not using the automatic scaling feature.
|
|
15
|
+
* @param {number} x - x scaling multiplier
|
|
16
|
+
* @param {number} y - y scaling multiplier
|
|
17
|
+
*/
|
|
18
|
+
function scale(renderer, x, y) {
|
|
19
|
+
var canvas = renderer.getCanvas();
|
|
20
|
+
var context = renderer.getContext();
|
|
21
|
+
var settings = renderer.settings;
|
|
22
|
+
var pixelRatio = devicePixelRatio;
|
|
23
|
+
|
|
24
|
+
var w = settings.zoomX = canvas.width * x * pixelRatio;
|
|
25
|
+
var h = settings.zoomY = canvas.height * y * pixelRatio;
|
|
26
|
+
|
|
27
|
+
// update the global scale variable
|
|
28
|
+
renderer.scaleRatio.set(x * pixelRatio, y * pixelRatio);
|
|
29
|
+
|
|
30
|
+
// adjust CSS style based on device pixel ratio
|
|
31
|
+
canvas.style.width = (w / pixelRatio) + "px";
|
|
32
|
+
canvas.style.height = (h / pixelRatio) + "px";
|
|
33
|
+
|
|
34
|
+
// if anti-alias and blend mode were resetted (e.g. Canvas mode)
|
|
35
|
+
renderer.setAntiAlias(context, settings.antiAlias);
|
|
36
|
+
renderer.setBlendMode(settings.blendMode, context);
|
|
37
|
+
|
|
38
|
+
// force repaint
|
|
39
|
+
game.repaint();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* callback for window resize event
|
|
44
|
+
*/
|
|
45
|
+
function onresize(renderer) {
|
|
46
|
+
var settings = renderer.settings;
|
|
47
|
+
var scaleX = 1, scaleY = 1;
|
|
48
|
+
|
|
49
|
+
if (settings.autoScale) {
|
|
50
|
+
|
|
51
|
+
// set max the canvas max size if CSS values are defined
|
|
52
|
+
var canvasMaxWidth = Infinity;
|
|
53
|
+
var canvasMaxHeight = Infinity;
|
|
54
|
+
|
|
55
|
+
if (globalThis.getComputedStyle) {
|
|
56
|
+
var style = globalThis.getComputedStyle(renderer.getCanvas(), null);
|
|
57
|
+
canvasMaxWidth = parseInt(style.maxWidth, 10) || Infinity;
|
|
58
|
+
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// get the maximum canvas size within the parent div containing the canvas container
|
|
62
|
+
var nodeBounds = getParentBounds(game.getParentElement());
|
|
63
|
+
|
|
64
|
+
var _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
65
|
+
var _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
66
|
+
|
|
67
|
+
// calculate final canvas width & height
|
|
68
|
+
var screenRatio = _max_width / _max_height;
|
|
69
|
+
|
|
70
|
+
if ((settings.scaleMethod === "fill-min" && screenRatio > renderer.designRatio) ||
|
|
71
|
+
(settings.scaleMethod === "fill-max" && screenRatio < renderer.designRatio) ||
|
|
72
|
+
(settings.scaleMethod === "flex-width")
|
|
73
|
+
) {
|
|
74
|
+
// resize the display canvas to fill the parent container
|
|
75
|
+
var sWidth = Math.min(canvasMaxWidth, settings.height * screenRatio);
|
|
76
|
+
scaleX = scaleY = _max_width / sWidth;
|
|
77
|
+
renderer.resize(Math.floor(sWidth), settings.height);
|
|
78
|
+
}
|
|
79
|
+
else if ((settings.scaleMethod === "fill-min" && screenRatio < renderer.designRatio) ||
|
|
80
|
+
(settings.scaleMethod === "fill-max" && screenRatio > renderer.designRatio) ||
|
|
81
|
+
(settings.scaleMethod === "flex-height")
|
|
82
|
+
) {
|
|
83
|
+
// resize the display canvas to fill the parent container
|
|
84
|
+
var sHeight = Math.min(canvasMaxHeight, settings.width * (_max_height / _max_width));
|
|
85
|
+
scaleX = scaleY = _max_height / sHeight;
|
|
86
|
+
renderer.resize(settings.width, Math.floor(sHeight));
|
|
87
|
+
}
|
|
88
|
+
else if (settings.scaleMethod === "flex") {
|
|
89
|
+
// resize the display canvas to fill the parent container
|
|
90
|
+
renderer.resize(Math.floor(_max_width), Math.floor(_max_height));
|
|
91
|
+
}
|
|
92
|
+
else if (settings.scaleMethod === "stretch") {
|
|
93
|
+
// scale the display canvas to fit with the parent container
|
|
94
|
+
scaleX = _max_width / settings.width;
|
|
95
|
+
scaleY = _max_height / settings.height;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// scale the display canvas to fit the parent container
|
|
99
|
+
// make sure we maintain the original aspect ratio
|
|
100
|
+
if (screenRatio < renderer.designRatio) {
|
|
101
|
+
scaleX = scaleY = _max_width / settings.width;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
scaleX = scaleY = _max_height / settings.height;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// adjust scaling ratio based on the new scaling ratio
|
|
109
|
+
scale(renderer, scaleX, scaleY);
|
|
110
|
+
} else {
|
|
111
|
+
// adjust scaling ratio based on the given settings
|
|
112
|
+
scale(renderer, settings.scale, settings.scale);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { onresize };
|