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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"type": "module",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@teppeis/multimaps": "^2.0.0",
|
|
56
|
-
"core-js": "^3.
|
|
56
|
+
"core-js": "^3.27.0",
|
|
57
57
|
"earcut": "2.2.4",
|
|
58
58
|
"eventemitter3": "^5.0.0",
|
|
59
59
|
"howler": "2.2.3"
|
|
@@ -61,30 +61,30 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/eslint-parser": "^7.19.1",
|
|
63
63
|
"@babel/plugin-syntax-import-assertions": "^7.20.0",
|
|
64
|
-
"@fastify/static": "^6.
|
|
64
|
+
"@fastify/static": "^6.6.0",
|
|
65
65
|
"@melonjs/webdoc-theme": "^1.1.1",
|
|
66
|
-
"@rollup/plugin-commonjs": "^
|
|
66
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
67
67
|
"@rollup/plugin-image": "^3.0.1",
|
|
68
68
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
69
|
-
"@rollup/plugin-replace": "^5.0.
|
|
69
|
+
"@rollup/plugin-replace": "^5.0.2",
|
|
70
70
|
"@types/offscreencanvas": "^2019.7.0",
|
|
71
71
|
"@webdoc/cli": "^2.2.0",
|
|
72
|
-
"chromedriver": "^
|
|
72
|
+
"chromedriver": "^108.0.0",
|
|
73
73
|
"cross-env": "^7.0.3",
|
|
74
74
|
"del-cli": "^5.0.0",
|
|
75
|
-
"eslint": "^8.
|
|
75
|
+
"eslint": "^8.30.0",
|
|
76
76
|
"eslint-plugin-jsdoc": "^39.6.4",
|
|
77
77
|
"expect": "^29.3.1",
|
|
78
78
|
"expect-mocha-image-snapshot": "^2.0.14",
|
|
79
79
|
"fastify": "^4.10.2",
|
|
80
|
-
"mocha": "^10.
|
|
80
|
+
"mocha": "^10.2.0",
|
|
81
81
|
"npm-self-link": "^1.1.7",
|
|
82
|
-
"puppeteer": "^19.
|
|
83
|
-
"rollup": "^3.
|
|
82
|
+
"puppeteer": "^19.4.1",
|
|
83
|
+
"rollup": "^3.8.1",
|
|
84
84
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
85
85
|
"rollup-plugin-string": "^3.0.0",
|
|
86
|
-
"terser": "^5.16.
|
|
87
|
-
"typescript": "^4.9.
|
|
86
|
+
"terser": "^5.16.1",
|
|
87
|
+
"typescript": "^4.9.4"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "npm run lint && rollup -c --silent",
|
|
@@ -99,6 +99,6 @@
|
|
|
99
99
|
"serve": "python3 -m http.server",
|
|
100
100
|
"prepublishOnly": "npm run dist && npm run test",
|
|
101
101
|
"clean": "del-cli --force build/*.* dist/*.* docs",
|
|
102
|
-
"types": "tsc
|
|
102
|
+
"types": "tsc"
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -12,9 +12,15 @@ import World from "./../physics/world.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export default class Application {
|
|
14
14
|
constructor() {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* the parent HTML element holding the main canvas of this application
|
|
18
|
+
* @type {HTMLElement}
|
|
19
|
+
*/
|
|
20
|
+
this.parentElement = undefined;
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
23
|
+
* the active stage "default" camera
|
|
18
24
|
* @type {Camera2d}
|
|
19
25
|
*/
|
|
20
26
|
this.viewport = undefined;
|
|
@@ -22,7 +28,6 @@ import World from "./../physics/world.js";
|
|
|
22
28
|
/**
|
|
23
29
|
* a reference to the game world, <br>
|
|
24
30
|
* a world is a virtual environment containing all the game objects
|
|
25
|
-
* @public
|
|
26
31
|
* @type {World}
|
|
27
32
|
*/
|
|
28
33
|
this.world = undefined;
|
|
@@ -30,7 +35,6 @@ import World from "./../physics/world.js";
|
|
|
30
35
|
/**
|
|
31
36
|
* when true, all objects will be added under the root world container.<br>
|
|
32
37
|
* When false, a `me.Container` object will be created for each corresponding groups
|
|
33
|
-
* @public
|
|
34
38
|
* @type {boolean}
|
|
35
39
|
* @default true
|
|
36
40
|
*/
|
|
@@ -39,7 +43,6 @@ import World from "./../physics/world.js";
|
|
|
39
43
|
/**
|
|
40
44
|
* Specify the property to be used when sorting renderables.
|
|
41
45
|
* Accepted values : "x", "y", "z"
|
|
42
|
-
* @public
|
|
43
46
|
* @type {string}
|
|
44
47
|
* @default "z"
|
|
45
48
|
*/
|
|
@@ -50,13 +53,17 @@ import World from "./../physics/world.js";
|
|
|
50
53
|
* Use this value to implement frame prediction in drawing events,
|
|
51
54
|
* for creating smooth motion while running game update logic at
|
|
52
55
|
* a lower fps.
|
|
53
|
-
* @public
|
|
54
56
|
* @type {DOMHighResTimeStamp}
|
|
55
|
-
* @name lastUpdate
|
|
56
|
-
* @memberof Application
|
|
57
57
|
*/
|
|
58
58
|
this.lastUpdate = 0;
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* true when this app instance has been initialized
|
|
62
|
+
* @type {boolean}
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
this.isInitialized = false;
|
|
66
|
+
|
|
60
67
|
// to know when we have to refresh the display
|
|
61
68
|
this.isDirty = true;
|
|
62
69
|
|
|
@@ -89,6 +96,7 @@ import World from "./../physics/world.js";
|
|
|
89
96
|
// set the reference to this application instance
|
|
90
97
|
this.world.app = this;
|
|
91
98
|
this.lastUpdate = globalThis.performance.now();
|
|
99
|
+
this.isInitialized = true;
|
|
92
100
|
event.emit(event.GAME_INIT, this);
|
|
93
101
|
}
|
|
94
102
|
|
|
@@ -140,12 +148,11 @@ import World from "./../physics/world.js";
|
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
/**
|
|
143
|
-
* Returns the parent
|
|
144
|
-
* @
|
|
145
|
-
* @returns {Container}
|
|
151
|
+
* Returns the parent HTML Element holding the main canvas of this application
|
|
152
|
+
* @returns {HTMLElement}
|
|
146
153
|
*/
|
|
147
|
-
|
|
148
|
-
return
|
|
154
|
+
getParentElement() {
|
|
155
|
+
return this.parentElement;
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {preventDefault} from "./input.js";
|
|
2
2
|
import {getBindingKey, triggerKeyEvent} from "./keyboard.js";
|
|
3
|
-
import { renderer
|
|
3
|
+
import { renderer } from "./../video/video.js";
|
|
4
4
|
import { throttle } from "./../utils/function.js";
|
|
5
5
|
import { remove } from "./../utils/array.js";
|
|
6
6
|
import * as event from "./../system/event.js";
|
|
@@ -9,7 +9,6 @@ import pool from "./../system/pooling.js";
|
|
|
9
9
|
import * as device from "./../system/device.js";
|
|
10
10
|
import Pointer from "./pointer.js";
|
|
11
11
|
import Rect from "./../geometries/rectangle.js";
|
|
12
|
-
import Container from "./../renderable/container.js";
|
|
13
12
|
import game from "./../game.js";
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -195,7 +194,7 @@ function enablePointerEvent() {
|
|
|
195
194
|
if (device.hasPointerLockSupport) {
|
|
196
195
|
document.addEventListener("pointerlockchange", () => {
|
|
197
196
|
// change the locked status accordingly
|
|
198
|
-
locked = document.pointerLockElement ===
|
|
197
|
+
locked = document.pointerLockElement === game.getParentElement();
|
|
199
198
|
// emit the corresponding internal event
|
|
200
199
|
event.emit(event.POINTERLOCKCHANGE, locked);
|
|
201
200
|
}, true);
|
|
@@ -287,7 +286,7 @@ function dispatchEvent(normalizedEvents) {
|
|
|
287
286
|
}
|
|
288
287
|
|
|
289
288
|
// fetch valid candiates from the game world container
|
|
290
|
-
var candidates = game.world.broadphase.retrieve(currentPointer,
|
|
289
|
+
var candidates = game.world.broadphase.retrieve(currentPointer, game.world._sortReverseZ);
|
|
291
290
|
|
|
292
291
|
// add the main game viewport to the list of candidates
|
|
293
292
|
candidates = candidates.concat([ game.viewport ]);
|
|
@@ -560,7 +559,7 @@ export function globalToLocal(x, y, v) {
|
|
|
560
559
|
var pixelRatio = globalThis.devicePixelRatio || 1;
|
|
561
560
|
x -= rect.left + (globalThis.pageXOffset || 0);
|
|
562
561
|
y -= rect.top + (globalThis.pageYOffset || 0);
|
|
563
|
-
var scale = scaleRatio;
|
|
562
|
+
var scale = renderer.scaleRatio;
|
|
564
563
|
if (scale.x !== 1.0 || scale.y !== 1.0) {
|
|
565
564
|
x /= scale.x;
|
|
566
565
|
y /= scale.y;
|
|
@@ -786,7 +785,7 @@ export function releaseAllPointerEvents(region) {
|
|
|
786
785
|
*/
|
|
787
786
|
export function requestPointerLock() {
|
|
788
787
|
if (device.hasPointerLockSupport) {
|
|
789
|
-
var element =
|
|
788
|
+
var element = game.getParentElement();
|
|
790
789
|
element.requestPointerLock();
|
|
791
790
|
return true;
|
|
792
791
|
}
|
package/src/plugin/plugin.js
CHANGED
|
@@ -122,7 +122,7 @@ export var plugin = {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// compatibility testing
|
|
125
|
-
if (utils.checkVersion(instance.version) > 0) {
|
|
125
|
+
if (utils.checkVersion(instance.version, version) > 0) {
|
|
126
126
|
throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
|
|
127
127
|
}
|
|
128
128
|
|
package/src/system/device.js
CHANGED
|
@@ -462,7 +462,7 @@ export function enableSwipe(enable) {
|
|
|
462
462
|
*/
|
|
463
463
|
export function isFullscreen() {
|
|
464
464
|
if (hasFullscreenSupport) {
|
|
465
|
-
return !!(prefixed("fullscreenElement", document) || document.mozFullScreenElement);
|
|
465
|
+
return !!(prefixed("fullscreenElement", globalThis.document) || globalThis.document.mozFullScreenElement);
|
|
466
466
|
} else {
|
|
467
467
|
return false;
|
|
468
468
|
}
|
|
@@ -473,7 +473,7 @@ export function isFullscreen() {
|
|
|
473
473
|
* @function requestFullscreen
|
|
474
474
|
* @memberof device
|
|
475
475
|
* @public
|
|
476
|
-
* @param {
|
|
476
|
+
* @param {Element} [element] - the element to be set in full-screen mode.
|
|
477
477
|
* @example
|
|
478
478
|
* // add a keyboard shortcut to toggle Fullscreen mode on/off
|
|
479
479
|
* me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
|
|
@@ -502,7 +502,7 @@ export function requestFullscreen(element) {
|
|
|
502
502
|
*/
|
|
503
503
|
export function exitFullscreen() {
|
|
504
504
|
if (hasFullscreenSupport && isFullscreen()) {
|
|
505
|
-
document.exitFullscreen();
|
|
505
|
+
globalThis.document.exitFullscreen();
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
|
|
@@ -655,7 +655,7 @@ export function getElement(element) {
|
|
|
655
655
|
|
|
656
656
|
if (element !== "undefined") {
|
|
657
657
|
if (typeof element === "string") {
|
|
658
|
-
target = document.getElementById(element);
|
|
658
|
+
target = globalThis.document.getElementById(element);
|
|
659
659
|
} else if (typeof element === "object" && element.nodeType === Node.ELEMENT_NODE) {
|
|
660
660
|
target = element;
|
|
661
661
|
}
|
|
@@ -664,7 +664,7 @@ export function getElement(element) {
|
|
|
664
664
|
// fallback, if invalid target or non HTMLElement object
|
|
665
665
|
if (!target) {
|
|
666
666
|
//default to document.body
|
|
667
|
-
target = document.body;
|
|
667
|
+
target = globalThis.document.body;
|
|
668
668
|
}
|
|
669
669
|
|
|
670
670
|
return target;
|
|
@@ -681,7 +681,7 @@ export function getElement(element) {
|
|
|
681
681
|
* @returns {DOMRect} the size and position of the element relatively to the viewport
|
|
682
682
|
*/
|
|
683
683
|
export function getElementBounds(element) {
|
|
684
|
-
if (typeof element === "object" && element !== document.body && typeof element.getBoundingClientRect !== "undefined") {
|
|
684
|
+
if (typeof element === "object" && element !== globalThis.document.body && typeof element.getBoundingClientRect !== "undefined") {
|
|
685
685
|
return element.getBoundingClientRect();
|
|
686
686
|
} else {
|
|
687
687
|
domRect.width = domRect.right = globalThis.innerWidth;
|
|
@@ -716,7 +716,7 @@ export function getParentBounds(element) {
|
|
|
716
716
|
export function isWebGLSupported(options) {
|
|
717
717
|
let _supported = false;
|
|
718
718
|
try {
|
|
719
|
-
let canvas = document.createElement("canvas");
|
|
719
|
+
let canvas = globalThis.document.createElement("canvas");
|
|
720
720
|
let ctxOptions = {
|
|
721
721
|
stencil: true,
|
|
722
722
|
failIfMajorPerformanceCaveat: options.failIfMajorPerformanceCaveat
|
package/src/system/dom.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as event from "./event.js";
|
|
2
|
+
import { nodeJS } from "./platform.js";
|
|
2
3
|
|
|
3
4
|
// track if DOMContentLoaded was called already
|
|
4
5
|
let readyBound = false;
|
|
@@ -51,7 +52,7 @@ export function DOMContentLoaded(fn) {
|
|
|
51
52
|
// bind dom load event if not done yet
|
|
52
53
|
if (!readyBound) {
|
|
53
54
|
// directly call domReady if document is already "ready"
|
|
54
|
-
if (
|
|
55
|
+
if (nodeJS === true || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
|
|
55
56
|
// defer the fn call to ensure our script is fully loaded
|
|
56
57
|
globalThis.setTimeout(_domReady, 0);
|
|
57
58
|
}
|
package/src/utils/utils.js
CHANGED
|
@@ -3,9 +3,6 @@ import * as arrayUtils from "./array.js";
|
|
|
3
3
|
import * as fileUtils from "./file.js";
|
|
4
4
|
import * as stringUtils from "./string.js";
|
|
5
5
|
import * as fnUtils from "./function.js";
|
|
6
|
-
import { createCanvas } from "./../video/video.js";
|
|
7
|
-
import CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
8
|
-
import { version } from "./../index.js";
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* a collection of utility functions
|
|
@@ -24,35 +21,13 @@ var utils = {
|
|
|
24
21
|
string : stringUtils,
|
|
25
22
|
function : fnUtils,
|
|
26
23
|
|
|
27
|
-
/**
|
|
28
|
-
* Get image pixels
|
|
29
|
-
* @public
|
|
30
|
-
* @memberof utils
|
|
31
|
-
* @name getPixels
|
|
32
|
-
* @param {HTMLImageElement|HTMLCanvasElement} image - Image to read
|
|
33
|
-
* @returns {ImageData} ImageData object
|
|
34
|
-
*/
|
|
35
|
-
getPixels : function (image) {
|
|
36
|
-
if (image instanceof HTMLImageElement) {
|
|
37
|
-
var _context = CanvasRenderer.getContext2d(
|
|
38
|
-
createCanvas(image.width, image.height)
|
|
39
|
-
);
|
|
40
|
-
_context.drawImage(image, 0, 0);
|
|
41
|
-
return _context.getImageData(0, 0, image.width, image.height);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// canvas !
|
|
45
|
-
return image.getContext("2d").getImageData(0, 0, image.width, image.height);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
|
|
49
24
|
/**
|
|
50
25
|
* Compare two version strings
|
|
51
26
|
* @public
|
|
52
27
|
* @memberof utils
|
|
53
28
|
* @name checkVersion
|
|
54
|
-
* @param {string} first -
|
|
55
|
-
* @param {string}
|
|
29
|
+
* @param {string} first - Ffrst version string to compare
|
|
30
|
+
* @param {string} second - second version string to compare
|
|
56
31
|
* @returns {number} comparison result <br>< 0 : first < second<br>
|
|
57
32
|
* 0 : first == second<br>
|
|
58
33
|
* > 0 : first > second
|
|
@@ -63,7 +38,7 @@ var utils = {
|
|
|
63
38
|
* );
|
|
64
39
|
* }
|
|
65
40
|
*/
|
|
66
|
-
checkVersion : function (first, second
|
|
41
|
+
checkVersion : function (first, second) {
|
|
67
42
|
var a = first.split(".");
|
|
68
43
|
var b = second.split(".");
|
|
69
44
|
var len = Math.min(a.length, b.length);
|
package/src/video/renderer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Color from "./../math/color.js";
|
|
2
2
|
import Matrix3d from "./../math/matrix3.js";
|
|
3
|
-
import { createCanvas
|
|
3
|
+
import { createCanvas } from "./video.js";
|
|
4
4
|
import * as event from "./../system/event.js";
|
|
5
|
-
import
|
|
5
|
+
import { platform } from "../system/device.js";
|
|
6
6
|
import { setPrefixed } from "./../utils/agent.js";
|
|
7
7
|
import Rect from "./../geometries/rectangle.js";
|
|
8
8
|
import RoundRect from "./../geometries/roundrect.js";
|
|
@@ -11,6 +11,7 @@ import Polygon from "./../geometries/poly.js";
|
|
|
11
11
|
import Line from "./../geometries/line.js";
|
|
12
12
|
import Bounds from "./../physics/bounds.js";
|
|
13
13
|
import Path2D from "./../geometries/path2d.js";
|
|
14
|
+
import Vector2d from "../math/vector2.js";
|
|
14
15
|
import Point from "../geometries/point.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -41,6 +42,20 @@ import Point from "../geometries/point.js";
|
|
|
41
42
|
*/
|
|
42
43
|
this.settings = options;
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* the requested video size ratio
|
|
47
|
+
* @public
|
|
48
|
+
* @type {Number}
|
|
49
|
+
*/
|
|
50
|
+
this.designRatio = this.settings.width / this.settings.height;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* the scaling ratio to be applied to the main canvas
|
|
54
|
+
* @type {Vector2d}
|
|
55
|
+
* @default <1,1>
|
|
56
|
+
*/
|
|
57
|
+
this.scaleRatio = new Vector2d(this.settings.scale, this.settings.scale);
|
|
58
|
+
|
|
44
59
|
/**
|
|
45
60
|
* true if the current rendering context is valid
|
|
46
61
|
* @default true
|
|
@@ -70,7 +85,7 @@ import Point from "../geometries/point.js";
|
|
|
70
85
|
this.currentBlendMode = "none";
|
|
71
86
|
|
|
72
87
|
// create the main screen canvas
|
|
73
|
-
if (
|
|
88
|
+
if (platform.ejecta === true) {
|
|
74
89
|
// a main canvas is already automatically created by Ejecta
|
|
75
90
|
this.canvas = document.getElementById("canvas");
|
|
76
91
|
} else if (typeof globalThis.canvas !== "undefined") {
|
|
@@ -94,9 +109,9 @@ import Point from "../geometries/point.js";
|
|
|
94
109
|
// default uvOffset
|
|
95
110
|
this.uvOffset = 0;
|
|
96
111
|
|
|
97
|
-
// reset the
|
|
112
|
+
// reset the renderer on game reset
|
|
98
113
|
event.on(event.GAME_RESET, () => {
|
|
99
|
-
|
|
114
|
+
this.reset();
|
|
100
115
|
});
|
|
101
116
|
}
|
|
102
117
|
|
|
@@ -323,8 +338,6 @@ import Point from "../geometries/point.js";
|
|
|
323
338
|
|
|
324
339
|
/**
|
|
325
340
|
* fill the given shape
|
|
326
|
-
* @name fill
|
|
327
|
-
* @memberof Renderer
|
|
328
341
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to fill
|
|
329
342
|
*/
|
|
330
343
|
fill(shape) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCanvas } from "./../video.js";
|
|
2
2
|
import { setPrefixed } from "./../../utils/agent.js";
|
|
3
|
+
import { clamp } from "../../math/math.js";
|
|
3
4
|
|
|
4
5
|
// default canvas settings
|
|
5
6
|
var defaultAttributes = {
|
|
@@ -97,6 +98,24 @@ class CanvasTexture {
|
|
|
97
98
|
this.canvas.height = Math.round(height);
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Returns an ImageData object representing the underlying pixel data for a specified portion of this canvas texture
|
|
103
|
+
* @param {number} x - The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
104
|
+
* @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
105
|
+
* @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
|
|
106
|
+
* @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
|
|
107
|
+
* @return {ImageData} The ImageData extracted from this CanvasTexture.
|
|
108
|
+
*/
|
|
109
|
+
getImageData(x, y, width, height) {
|
|
110
|
+
// clamp values
|
|
111
|
+
x = clamp(Math.floor(x), 0, this.canvas.width - 1);
|
|
112
|
+
y = clamp(Math.floor(y), 0, this.canvas.height - 1);
|
|
113
|
+
width = clamp(width, 1, this.canvas.width - x);
|
|
114
|
+
height = clamp(height, 1, this.canvas.height - y);
|
|
115
|
+
// return imageData
|
|
116
|
+
return this.context.getImageData(x, y, width, height);
|
|
117
|
+
}
|
|
118
|
+
|
|
100
119
|
/**
|
|
101
120
|
* @ignore
|
|
102
121
|
*/
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as device from "./../../system/device.js";
|
|
2
|
+
import game from "./../../game.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* scale the "displayed" canvas by the given scalar.
|
|
6
|
+
* this will modify the size of canvas element directly.
|
|
7
|
+
* Only use this if you are not using the automatic scaling feature.
|
|
8
|
+
* @param {number} x - x scaling multiplier
|
|
9
|
+
* @param {number} y - y scaling multiplier
|
|
10
|
+
*/
|
|
11
|
+
function scale(renderer, x, y) {
|
|
12
|
+
var canvas = renderer.getCanvas();
|
|
13
|
+
var context = renderer.getContext();
|
|
14
|
+
var settings = renderer.settings;
|
|
15
|
+
var pixelRatio = device.devicePixelRatio;
|
|
16
|
+
|
|
17
|
+
var w = settings.zoomX = canvas.width * x * pixelRatio;
|
|
18
|
+
var h = settings.zoomY = canvas.height * y * pixelRatio;
|
|
19
|
+
|
|
20
|
+
// update the global scale variable
|
|
21
|
+
renderer.scaleRatio.set(x * pixelRatio, y * pixelRatio);
|
|
22
|
+
|
|
23
|
+
// adjust CSS style based on device pixel ratio
|
|
24
|
+
canvas.style.width = (w / pixelRatio) + "px";
|
|
25
|
+
canvas.style.height = (h / pixelRatio) + "px";
|
|
26
|
+
|
|
27
|
+
// if anti-alias and blend mode were resetted (e.g. Canvas mode)
|
|
28
|
+
renderer.setAntiAlias(context, settings.antiAlias);
|
|
29
|
+
renderer.setBlendMode(settings.blendMode, context);
|
|
30
|
+
|
|
31
|
+
// force repaint
|
|
32
|
+
game.repaint();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* callback for window resize event
|
|
37
|
+
*/
|
|
38
|
+
export function onresize(renderer) {
|
|
39
|
+
var settings = renderer.settings;
|
|
40
|
+
var scaleX = 1, scaleY = 1;
|
|
41
|
+
|
|
42
|
+
if (settings.autoScale) {
|
|
43
|
+
|
|
44
|
+
// set max the canvas max size if CSS values are defined
|
|
45
|
+
var canvasMaxWidth = Infinity;
|
|
46
|
+
var canvasMaxHeight = Infinity;
|
|
47
|
+
|
|
48
|
+
if (globalThis.getComputedStyle) {
|
|
49
|
+
var style = globalThis.getComputedStyle(renderer.getCanvas(), null);
|
|
50
|
+
canvasMaxWidth = parseInt(style.maxWidth, 10) || Infinity;
|
|
51
|
+
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// get the maximum canvas size within the parent div containing the canvas container
|
|
55
|
+
var nodeBounds = device.getParentBounds(game.getParentElement());
|
|
56
|
+
|
|
57
|
+
var _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
58
|
+
var _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
59
|
+
|
|
60
|
+
// calculate final canvas width & height
|
|
61
|
+
var screenRatio = _max_width / _max_height;
|
|
62
|
+
|
|
63
|
+
if ((settings.scaleMethod === "fill-min" && screenRatio > renderer.designRatio) ||
|
|
64
|
+
(settings.scaleMethod === "fill-max" && screenRatio < renderer.designRatio) ||
|
|
65
|
+
(settings.scaleMethod === "flex-width")
|
|
66
|
+
) {
|
|
67
|
+
// resize the display canvas to fill the parent container
|
|
68
|
+
var sWidth = Math.min(canvasMaxWidth, settings.height * screenRatio);
|
|
69
|
+
scaleX = scaleY = _max_width / sWidth;
|
|
70
|
+
renderer.resize(Math.floor(sWidth), settings.height);
|
|
71
|
+
}
|
|
72
|
+
else if ((settings.scaleMethod === "fill-min" && screenRatio < renderer.designRatio) ||
|
|
73
|
+
(settings.scaleMethod === "fill-max" && screenRatio > renderer.designRatio) ||
|
|
74
|
+
(settings.scaleMethod === "flex-height")
|
|
75
|
+
) {
|
|
76
|
+
// resize the display canvas to fill the parent container
|
|
77
|
+
var sHeight = Math.min(canvasMaxHeight, settings.width * (_max_height / _max_width));
|
|
78
|
+
scaleX = scaleY = _max_height / sHeight;
|
|
79
|
+
renderer.resize(settings.width, Math.floor(sHeight));
|
|
80
|
+
}
|
|
81
|
+
else if (settings.scaleMethod === "flex") {
|
|
82
|
+
// resize the display canvas to fill the parent container
|
|
83
|
+
renderer.resize(Math.floor(_max_width), Math.floor(_max_height));
|
|
84
|
+
}
|
|
85
|
+
else if (settings.scaleMethod === "stretch") {
|
|
86
|
+
// scale the display canvas to fit with the parent container
|
|
87
|
+
scaleX = _max_width / settings.width;
|
|
88
|
+
scaleY = _max_height / settings.height;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// scale the display canvas to fit the parent container
|
|
92
|
+
// make sure we maintain the original aspect ratio
|
|
93
|
+
if (screenRatio < renderer.designRatio) {
|
|
94
|
+
scaleX = scaleY = _max_width / settings.width;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
scaleX = scaleY = _max_height / settings.height;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// adjust scaling ratio based on the new scaling ratio
|
|
102
|
+
scale(renderer, scaleX, scaleY);
|
|
103
|
+
} else {
|
|
104
|
+
// adjust scaling ratio based on the given settings
|
|
105
|
+
scale(renderer, settings.scale, settings.scale);
|
|
106
|
+
}
|
|
107
|
+
}
|