melonjs 14.1.2 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +173 -22
- package/dist/melonjs.mjs/application/header.js +34 -0
- package/dist/melonjs.mjs/application/resize.js +119 -0
- package/dist/melonjs.mjs/application/settings.js +28 -0
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +2 -2
- 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 +41 -61
- 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 +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +7 -8
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- package/dist/melonjs.mjs/level/level.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +3 -3
- package/dist/melonjs.mjs/physics/detector.js +174 -146
- 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 +10 -30
- 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 +3 -87
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/melonjs.mjs/state/state.js +2 -2
- package/dist/melonjs.mjs/system/device.js +9 -29
- 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 +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 +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 +4 -1
- package/dist/melonjs.mjs/video/renderer.js +26 -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 +21 -1
- package/dist/melonjs.mjs/video/utils/autodetect.js +27 -0
- package/dist/melonjs.mjs/video/utils/resize.js +116 -0
- package/dist/melonjs.mjs/video/video.js +20 -294
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -3
- 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 +20 -2
- 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 +4 -1
- package/dist/melonjs.module.js +28551 -26959
- package/dist/types/application/application.d.ts +144 -0
- package/dist/types/application/header.d.ts +5 -0
- package/dist/types/application/resize.d.ts +5 -0
- package/dist/types/application/settings.d.ts +18 -0
- package/dist/types/audio/audio.d.ts +267 -0
- package/dist/types/camera/camera2d.d.ts +289 -0
- package/dist/types/entity/entity.d.ts +98 -0
- package/{src/game.js → dist/types/game.d.ts} +3 -14
- package/dist/types/geometries/ellipse.d.ts +154 -0
- package/dist/types/geometries/line.d.ts +11 -0
- package/dist/types/geometries/path2d.d.ts +121 -0
- package/dist/types/geometries/point.d.ts +53 -0
- package/dist/types/geometries/poly.d.ts +222 -0
- package/dist/types/geometries/rectangle.d.ts +176 -0
- package/dist/types/geometries/roundrect.d.ts +52 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input/gamepad.d.ts +95 -0
- package/dist/types/input/input.d.ts +15 -0
- package/dist/types/input/keyboard.d.ts +205 -0
- package/dist/types/input/pointer.d.ts +270 -0
- package/dist/types/input/pointerevent.d.ts +181 -0
- package/dist/types/lang/deprecated.d.ts +53 -0
- package/dist/types/level/level.d.ts +134 -0
- package/dist/types/level/tiled/TMXGroup.d.ts +82 -0
- package/dist/types/level/tiled/TMXLayer.d.ts +180 -0
- package/dist/types/level/tiled/TMXObject.d.ts +195 -0
- package/dist/types/level/tiled/TMXTile.d.ts +78 -0
- package/dist/types/level/tiled/TMXTileMap.d.ts +180 -0
- package/dist/types/level/tiled/TMXTileset.d.ts +94 -0
- package/dist/types/level/tiled/TMXTilesetGroup.d.ts +32 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +47 -0
- package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +87 -0
- package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +55 -0
- package/dist/types/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +43 -0
- package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +75 -0
- package/dist/types/level/tiled/renderer/TMXStaggeredRenderer.d.ts +8 -0
- package/dist/types/loader/loader.d.ts +181 -0
- package/dist/types/loader/loadingscreen.d.ts +18 -0
- package/dist/types/math/color.d.ts +170 -0
- package/dist/types/math/math.d.ts +165 -0
- package/dist/types/math/matrix2.d.ts +209 -0
- package/dist/types/math/matrix3.d.ts +236 -0
- package/dist/types/math/observable_vector2.d.ts +278 -0
- package/dist/types/math/observable_vector3.d.ts +277 -0
- package/dist/types/math/vector2.d.ts +327 -0
- package/dist/types/math/vector3.d.ts +332 -0
- package/dist/types/particles/emitter.d.ts +188 -0
- package/dist/types/particles/particle.d.ts +32 -0
- package/dist/types/particles/settings.d.ts +32 -0
- package/dist/types/physics/body.d.ts +330 -0
- package/dist/types/physics/bounds.d.ts +250 -0
- package/dist/types/physics/collision.d.ts +44 -0
- package/dist/types/physics/detector.d.ts +64 -0
- package/dist/types/physics/quadtree.d.ts +79 -0
- package/dist/types/physics/response.d.ts +37 -0
- package/dist/types/physics/sat.d.ts +48 -0
- package/dist/types/physics/world.d.ts +83 -0
- package/dist/types/plugin/plugin.d.ts +10 -0
- package/dist/types/polyfill/console.d.ts +0 -0
- package/dist/types/polyfill/index.d.ts +1 -0
- package/dist/types/polyfill/performance.d.ts +0 -0
- package/dist/types/polyfill/requestAnimationFrame.d.ts +1 -0
- package/dist/types/polyfill/roundrect.d.ts +0 -0
- package/dist/types/renderable/collectable.d.ts +19 -0
- package/dist/types/renderable/colorlayer.d.ts +28 -0
- package/dist/types/renderable/container.d.ts +302 -0
- package/dist/types/renderable/dragndrop.d.ts +118 -0
- package/dist/types/renderable/imagelayer.d.ts +106 -0
- package/dist/types/renderable/light2d.d.ts +58 -0
- package/dist/types/renderable/nineslicesprite.d.ts +59 -0
- package/dist/types/renderable/renderable.d.ts +402 -0
- package/dist/types/renderable/sprite.d.ts +268 -0
- package/dist/types/renderable/trigger.d.ts +61 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +95 -0
- package/dist/types/renderable/ui/uispriteelement.d.ts +127 -0
- package/dist/types/renderable/ui/uitextbutton.d.ts +54 -0
- package/dist/types/state/stage.d.ts +116 -0
- package/dist/types/state/state.d.ts +170 -0
- package/dist/types/system/device.d.ts +579 -0
- package/dist/types/system/dom.d.ts +1 -0
- package/dist/types/system/event.d.ts +473 -0
- package/dist/types/system/platform.d.ts +31 -0
- package/dist/types/system/pooling.d.ts +101 -0
- package/dist/types/system/save.d.ts +25 -0
- package/dist/types/system/timer.d.ts +126 -0
- package/dist/types/text/bitmaptext.d.ts +151 -0
- package/dist/types/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/text/glyph.d.ts +28 -0
- package/dist/types/text/text.d.ts +173 -0
- package/dist/types/text/textmetrics.d.ts +47 -0
- package/dist/types/text/textstyle.d.ts +5 -0
- package/dist/types/tweens/easing.d.ts +46 -0
- package/dist/types/tweens/interpolation.d.ts +18 -0
- package/dist/types/tweens/tween.d.ts +195 -0
- package/dist/types/utils/agent.d.ts +21 -0
- package/dist/types/utils/array.d.ts +39 -0
- package/dist/types/utils/file.d.ts +18 -0
- package/dist/types/utils/function.d.ts +32 -0
- package/dist/types/utils/string.d.ts +50 -0
- package/dist/types/utils/utils.d.ts +17 -0
- package/dist/types/video/canvas/canvas_renderer.d.ts +380 -0
- package/dist/types/video/renderer.d.ts +222 -0
- package/dist/types/video/texture/atlas.d.ts +201 -0
- package/dist/types/video/texture/cache.d.ts +45 -0
- package/dist/types/video/texture/canvas_texture.d.ts +78 -0
- package/dist/types/video/utils/autodetect.d.ts +7 -0
- package/dist/types/video/utils/resize.d.ts +4 -0
- package/dist/types/video/video.d.ts +92 -0
- package/dist/types/video/webgl/buffer/vertex.d.ts +56 -0
- package/dist/types/video/webgl/glshader.d.ts +93 -0
- package/dist/types/video/webgl/utils/attributes.d.ts +4 -0
- package/dist/types/video/webgl/utils/precision.d.ts +13 -0
- package/dist/types/video/webgl/utils/program.d.ts +5 -0
- package/dist/types/video/webgl/utils/string.d.ts +5 -0
- package/dist/types/video/webgl/utils/uniforms.d.ts +4 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +174 -0
- package/dist/types/video/webgl/webgl_renderer.d.ts +429 -0
- package/package.json +14 -14
- package/src/application/application.js +171 -20
- package/src/application/header.js +25 -0
- package/src/application/resize.js +110 -0
- package/src/application/settings.js +19 -0
- package/src/camera/camera2d.js +1 -1
- package/src/index.js +34 -23
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +6 -7
- package/src/level/level.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/loader/loadingscreen.js +1 -1
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +172 -145
- package/src/physics/world.js +10 -30
- package/src/plugin/plugin.js +1 -1
- package/src/renderable/container.js +7 -91
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/trigger.js +1 -1
- package/src/renderable/ui/uibaseelement.js +1 -1
- package/src/state/stage.js +1 -1
- package/src/state/state.js +1 -1
- package/src/system/device.js +7 -27
- package/src/system/dom.js +2 -1
- package/src/tweens/tween.js +1 -1
- package/src/utils/utils.js +3 -28
- package/src/video/canvas/canvas_renderer.js +3 -0
- package/src/video/renderer.js +27 -7
- package/src/video/texture/canvas_texture.js +20 -0
- package/src/video/utils/autodetect.js +18 -0
- package/src/video/video.js +17 -291
- package/src/video/webgl/glshader.js +3 -4
- package/src/video/webgl/utils/precision.js +18 -0
- package/src/video/webgl/webgl_renderer.js +3 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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
|
|
@@ -9,7 +9,7 @@ import Renderable from './renderable.js';
|
|
|
9
9
|
import collision from '../physics/collision.js';
|
|
10
10
|
import Body from '../physics/body.js';
|
|
11
11
|
import level from '../level/level.js';
|
|
12
|
-
import game from '../
|
|
12
|
+
import { game } from '../index.js';
|
|
13
13
|
import pool from '../system/pooling.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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 { renderer } from '../video/video.js';
|
|
9
|
-
import game from '../
|
|
9
|
+
import { game } from '../index.js';
|
|
10
10
|
import Camera2d from '../camera/camera2d.js';
|
|
11
11
|
import Color from '../math/color.js';
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { pauseTrack, resumeTrack } from '../audio/audio.js';
|
|
9
9
|
import { defer } from '../utils/function.js';
|
|
10
10
|
import { on, VIDEO_INIT, BOOT, emit, STATE_STOP, STATE_PAUSE, STATE_RESTART, STATE_RESUME, STATE_CHANGE } from '../system/event.js';
|
|
11
|
-
import game from '../
|
|
11
|
+
import { game } from '../index.js';
|
|
12
12
|
import { focus } from '../system/device.js';
|
|
13
13
|
import Stage from './stage.js';
|
|
14
14
|
import DefaultLoadingScreen from '../loader/loadingscreen.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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
|
|
@@ -736,26 +736,6 @@ function isWebGLSupported(options) {
|
|
|
736
736
|
return _supported;
|
|
737
737
|
}
|
|
738
738
|
|
|
739
|
-
/**
|
|
740
|
-
* return the highest precision format supported by this device for GL Shaders
|
|
741
|
-
* @function getMaxShaderPrecision
|
|
742
|
-
* @memberof device
|
|
743
|
-
* @public
|
|
744
|
-
* @param {WebGLRenderingContext} gl
|
|
745
|
-
* @returns {boolean} "lowp", "mediump", or "highp"
|
|
746
|
-
*/
|
|
747
|
-
function getMaxShaderPrecision(gl) {
|
|
748
|
-
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
|
|
749
|
-
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0) {
|
|
750
|
-
return "highp";
|
|
751
|
-
}
|
|
752
|
-
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
|
|
753
|
-
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0) {
|
|
754
|
-
return "mediump";
|
|
755
|
-
}
|
|
756
|
-
return "lowp";
|
|
757
|
-
}
|
|
758
|
-
|
|
759
739
|
/**
|
|
760
740
|
* Makes a request to bring this device window to the front.
|
|
761
741
|
* @function focus
|
|
@@ -906,4 +886,4 @@ function vibrate(pattern) {
|
|
|
906
886
|
}
|
|
907
887
|
}
|
|
908
888
|
|
|
909
|
-
export { accelerationX, accelerationY, accelerationZ, alpha, autoFocus, beta, devicePixelRatio, enableSwipe, exitFullscreen, focus, gamma, getElement, getElementBounds,
|
|
889
|
+
export { accelerationX, accelerationY, accelerationZ, alpha, autoFocus, beta, devicePixelRatio, enableSwipe, exitFullscreen, focus, gamma, getElement, getElementBounds, getParentBounds, getParentElement, getScreenOrientation, getStorage, hasAccelerometer, hasDeviceOrientation, hasFullscreenSupport, hasHTML5Audio, hasPointerLockSupport, hasWebAudio, isFullscreen, isLandscape, isMobile, isPortrait, isWebGLSupported, language, localStorage, lockOrientation, maxTouchPoints, nativeBase64, offscreenCanvas, onDeviceRotate, onReady, pauseOnBlur, platform, pointerEvent, requestFullscreen, resumeOnFocus, screenOrientation, sound, stopOnBlur, touch, touchEvent, unlockOrientation, unwatchAccelerometer, unwatchDeviceOrientation, vibrate, watchAccelerometer, watchDeviceOrientation, wheel };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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.3.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 timer from '../system/timer.js';
|
|
9
9
|
import { on, STATE_RESUME, off } from '../system/event.js';
|
|
10
|
-
import game from '../
|
|
10
|
+
import { game } from '../index.js';
|
|
11
11
|
import { Easing } from './easing.js';
|
|
12
12
|
import { Interpolation } from './interpolation.js';
|
|
13
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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.3.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
|
|
@@ -52,6 +52,9 @@ import { emit, ONCONTEXT_LOST, ONCONTEXT_RESTORED } from '../../system/event.js'
|
|
|
52
52
|
this.uvOffset = 1;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// set the renderer type
|
|
56
|
+
this.type = "CANVAS";
|
|
57
|
+
|
|
55
58
|
// context lost & restore event for canvas
|
|
56
59
|
this.getCanvas().addEventListener("contextlost", (e) => {
|
|
57
60
|
e.preventDefault();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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
|
|
@@ -61,6 +76,13 @@ import Point from '../geometries/point.js';
|
|
|
61
76
|
*/
|
|
62
77
|
this.path2D = new Path2D();
|
|
63
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The renderer type : Canvas, WebGL, etc...
|
|
81
|
+
* (override this property with a specific value when implementing a custom renderer)
|
|
82
|
+
* @type {string}
|
|
83
|
+
*/
|
|
84
|
+
this.type = "Generic";
|
|
85
|
+
|
|
64
86
|
/**
|
|
65
87
|
* @ignore
|
|
66
88
|
*/
|
|
@@ -101,9 +123,9 @@ import Point from '../geometries/point.js';
|
|
|
101
123
|
// default uvOffset
|
|
102
124
|
this.uvOffset = 0;
|
|
103
125
|
|
|
104
|
-
// reset the
|
|
126
|
+
// reset the renderer on game reset
|
|
105
127
|
on(GAME_RESET, () => {
|
|
106
|
-
|
|
128
|
+
this.reset();
|
|
107
129
|
});
|
|
108
130
|
}
|
|
109
131
|
|
|
@@ -330,8 +352,6 @@ import Point from '../geometries/point.js';
|
|
|
330
352
|
|
|
331
353
|
/**
|
|
332
354
|
* fill the given shape
|
|
333
|
-
* @name fill
|
|
334
|
-
* @memberof Renderer
|
|
335
355
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to fill
|
|
336
356
|
*/
|
|
337
357
|
fill(shape) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.3.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,25 @@ 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
|
+
* (Note: when using getImageData(), it is highly recommended to use the `willReadFrequently` attribute when creatimg the corresponding canvas texture)
|
|
111
|
+
* @param {number} x - The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
112
|
+
* @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
113
|
+
* @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
|
|
114
|
+
* @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
|
|
115
|
+
* @return {ImageData} The ImageData extracted from this CanvasTexture.
|
|
116
|
+
*/
|
|
117
|
+
getImageData(x, y, width, height) {
|
|
118
|
+
// clamp values
|
|
119
|
+
x = clamp(Math.floor(x), 0, this.canvas.width - 1);
|
|
120
|
+
y = clamp(Math.floor(y), 0, this.canvas.height - 1);
|
|
121
|
+
width = clamp(width, 1, this.canvas.width - x);
|
|
122
|
+
height = clamp(height, 1, this.canvas.height - y);
|
|
123
|
+
// return imageData
|
|
124
|
+
return this.context.getImageData(x, y, width, height);
|
|
125
|
+
}
|
|
126
|
+
|
|
107
127
|
/**
|
|
108
128
|
* @ignore
|
|
109
129
|
*/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* melonJS Game Engine - v14.3.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 { isWebGLSupported } from '../../system/device.js';
|
|
9
|
+
import WebGLRenderer from '../webgl/webgl_renderer.js';
|
|
10
|
+
import CanvasRenderer from '../canvas/canvas_renderer.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Auto-detect the best renderer to use
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
function autoDetectRenderer(options) {
|
|
17
|
+
try {
|
|
18
|
+
if (isWebGLSupported(options)) {
|
|
19
|
+
return new WebGLRenderer(options);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.log("Error creating WebGL renderer :" + e.message);
|
|
23
|
+
}
|
|
24
|
+
return new CanvasRenderer(options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { autoDetectRenderer };
|