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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* create a simple 1 frame texture atlas based on the given parameters
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
export function createAtlas(width: any, height: any, name?: string, repeat?: string): {
|
|
6
|
+
meta: {
|
|
7
|
+
app: string;
|
|
8
|
+
size: {
|
|
9
|
+
w: any;
|
|
10
|
+
h: any;
|
|
11
|
+
};
|
|
12
|
+
repeat: string;
|
|
13
|
+
image: string;
|
|
14
|
+
};
|
|
15
|
+
frames: {
|
|
16
|
+
filename: string;
|
|
17
|
+
frame: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
w: any;
|
|
21
|
+
h: any;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @classdesc
|
|
27
|
+
* A Texture atlas class, currently supports : <br>
|
|
28
|
+
* - [TexturePacker]{@link http://www.codeandweb.com/texturepacker/} : through JSON export (standard and multipack texture atlas) <br>
|
|
29
|
+
* - [ShoeBox]{@link http://renderhjs.net/shoebox/} : through JSON export using the
|
|
30
|
+
* melonJS setting [file]{@link https://github.com/melonjs/melonJS/raw/master/media/shoebox_JSON_export.sbx} <br>
|
|
31
|
+
* - [Free Texture Packer]{@link http://free-tex-packer.com/app/} : through JSON export (standard and multipack texture atlas) <br>
|
|
32
|
+
* - Standard (fixed cell size) spritesheet : through a {framewidth:xx, frameheight:xx, anchorPoint:me.Vector2d} object
|
|
33
|
+
* );
|
|
34
|
+
*/
|
|
35
|
+
export class TextureAtlas {
|
|
36
|
+
/**
|
|
37
|
+
* @param {object|object[]} atlases - atlas information. See {@link loader.getJSON}
|
|
38
|
+
* @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] - Image source
|
|
39
|
+
* @param {boolean} [cache=false] - Use true to skip caching this Texture
|
|
40
|
+
* @example
|
|
41
|
+
* // create a texture atlas from a JSON Object
|
|
42
|
+
* game.texture = new me.TextureAtlas(
|
|
43
|
+
* me.loader.getJSON("texture")
|
|
44
|
+
* );
|
|
45
|
+
*
|
|
46
|
+
* // create a texture atlas from a multipack JSON Object
|
|
47
|
+
* game.texture = new me.TextureAtlas([
|
|
48
|
+
* me.loader.getJSON("texture-0"),
|
|
49
|
+
* me.loader.getJSON("texture-1"),
|
|
50
|
+
* me.loader.getJSON("texture-2")
|
|
51
|
+
* ]);
|
|
52
|
+
*
|
|
53
|
+
* // create a texture atlas for a spritesheet with an anchorPoint in the center of each frame
|
|
54
|
+
* game.texture = new me.TextureAtlas(
|
|
55
|
+
* {
|
|
56
|
+
* framewidth : 32,
|
|
57
|
+
* frameheight : 32,
|
|
58
|
+
* anchorPoint : new me.Vector2d(0.5, 0.5)
|
|
59
|
+
* },
|
|
60
|
+
* me.loader.getImage("spritesheet")
|
|
61
|
+
*/
|
|
62
|
+
constructor(atlases: object | object[], src?: string | string[] | HTMLCanvasElement | HTMLImageElement | HTMLImageElement[] | HTMLCanvasElement[] | undefined, cache?: boolean | undefined);
|
|
63
|
+
/**
|
|
64
|
+
* to identify the atlas format (e.g. texture packer)
|
|
65
|
+
* @ignore
|
|
66
|
+
*/
|
|
67
|
+
format: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* the texture source(s) itself
|
|
70
|
+
* @type {Map}
|
|
71
|
+
* @ignore
|
|
72
|
+
*/
|
|
73
|
+
sources: Map<any, any>;
|
|
74
|
+
/**
|
|
75
|
+
* the atlas dictionnaries
|
|
76
|
+
* @type {Map}
|
|
77
|
+
* @ignore
|
|
78
|
+
*/
|
|
79
|
+
atlases: Map<any, any>;
|
|
80
|
+
repeat: any;
|
|
81
|
+
/**
|
|
82
|
+
* build an atlas from the given data
|
|
83
|
+
* @ignore
|
|
84
|
+
*/
|
|
85
|
+
parse(data: any): {};
|
|
86
|
+
/**
|
|
87
|
+
* build an atlas from the given spritesheet
|
|
88
|
+
* @ignore
|
|
89
|
+
*/
|
|
90
|
+
parseFromSpriteSheet(data: any): {};
|
|
91
|
+
/**
|
|
92
|
+
* return the default or specified atlas dictionnary
|
|
93
|
+
* @param {string} [name] - atlas name in case of multipack textures
|
|
94
|
+
* @returns {object}
|
|
95
|
+
*/
|
|
96
|
+
getAtlas(name?: string | undefined): object;
|
|
97
|
+
/**
|
|
98
|
+
* return the format of the atlas dictionnary
|
|
99
|
+
* @returns {string} will return "texturepacker", or "ShoeBox", or "melonJS", or "Spritesheet (fixed cell size)"
|
|
100
|
+
*/
|
|
101
|
+
getFormat(): string;
|
|
102
|
+
/**
|
|
103
|
+
* return the source texture for the given region (or default one if none specified)
|
|
104
|
+
* @param {object} [region] - region name in case of multipack textures
|
|
105
|
+
* @returns {HTMLImageElement|HTMLCanvasElement}
|
|
106
|
+
*/
|
|
107
|
+
getTexture(region?: object | undefined): HTMLImageElement | HTMLCanvasElement;
|
|
108
|
+
/**
|
|
109
|
+
* add a region to the atlas
|
|
110
|
+
* @param {string} name - region mame
|
|
111
|
+
* @param {number} x - x origin of the region
|
|
112
|
+
* @param {number} y - y origin of the region
|
|
113
|
+
* @param {number} w - width of the region
|
|
114
|
+
* @param {number} h - height of the region
|
|
115
|
+
* @returns {object} the created region
|
|
116
|
+
*/
|
|
117
|
+
addRegion(name: string, x: number, y: number, w: number, h: number): object;
|
|
118
|
+
/**
|
|
119
|
+
* return a normalized region (or frame) information for the specified sprite name
|
|
120
|
+
* @param {string} name - name of the sprite
|
|
121
|
+
* @param {string} [atlas] - name of a specific atlas where to search for the region
|
|
122
|
+
* @returns {object}
|
|
123
|
+
*/
|
|
124
|
+
getRegion(name: string, atlas?: string | undefined): object;
|
|
125
|
+
/**
|
|
126
|
+
* return the uvs mapping for the given region
|
|
127
|
+
* @param {object} name - region (or frame) name
|
|
128
|
+
* @returns {Float32Array} region Uvs
|
|
129
|
+
*/
|
|
130
|
+
getUVs(name: object): Float32Array;
|
|
131
|
+
/**
|
|
132
|
+
* add uvs mapping for the given region
|
|
133
|
+
* @param {object} atlas - the atlas dictionnary where the region is define
|
|
134
|
+
* @param {object} name - region (or frame) name
|
|
135
|
+
* @param {number} w - the width of the region
|
|
136
|
+
* @param {number} h - the height of the region
|
|
137
|
+
* @returns {Float32Array} the created region UVs
|
|
138
|
+
*/
|
|
139
|
+
addUVs(atlas: object, name: object, w: number, h: number): Float32Array;
|
|
140
|
+
/**
|
|
141
|
+
* Create a sprite object using the first region found using the specified name
|
|
142
|
+
* @param {string} name - name of the sprite
|
|
143
|
+
* @param {object} [settings] - Additional settings passed to the {@link Sprite} contructor
|
|
144
|
+
* @param {boolean} [nineSlice=false] - if true returns a 9-slice sprite
|
|
145
|
+
* @returns {Sprite|NineSliceSprite}
|
|
146
|
+
* @example
|
|
147
|
+
* // create a new texture object under the `game` namespace
|
|
148
|
+
* game.texture = new me.TextureAtlas(
|
|
149
|
+
* me.loader.getJSON("texture"),
|
|
150
|
+
* me.loader.getImage("texture")
|
|
151
|
+
* );
|
|
152
|
+
* ...
|
|
153
|
+
* ...
|
|
154
|
+
* // create a new "coin" sprite
|
|
155
|
+
* var sprite = game.texture.createSpriteFromName("coin.png");
|
|
156
|
+
* // set the renderable position to bottom center
|
|
157
|
+
* sprite.anchorPoint.set(0.5, 1.0);
|
|
158
|
+
* ...
|
|
159
|
+
* ...
|
|
160
|
+
* // create a 9-slice sprite
|
|
161
|
+
* var dialogPanel = game.texture.createSpriteFromName(
|
|
162
|
+
* "rpg_dialo.png",
|
|
163
|
+
* // width & height are mandatory for 9-slice sprites
|
|
164
|
+
* { width: this.width, height: this.height },
|
|
165
|
+
* true
|
|
166
|
+
* );
|
|
167
|
+
*/
|
|
168
|
+
createSpriteFromName(name: string, settings?: object | undefined, nineSlice?: boolean | undefined): Sprite | NineSliceSprite;
|
|
169
|
+
/**
|
|
170
|
+
* Create an animation object using the first region found using all specified names
|
|
171
|
+
* @param {string[]|number[]} names - list of names for each sprite
|
|
172
|
+
* (when manually creating a Texture out of a spritesheet, only numeric values are authorized)
|
|
173
|
+
* @param {object} [settings] - Additional settings passed to the {@link Sprite} contructor
|
|
174
|
+
* @returns {Sprite}
|
|
175
|
+
* @example
|
|
176
|
+
* // create a new texture object under the `game` namespace
|
|
177
|
+
* game.texture = new me.TextureAtlas(
|
|
178
|
+
* me.loader.getJSON("texture"),
|
|
179
|
+
* me.loader.getImage("texture")
|
|
180
|
+
* );
|
|
181
|
+
*
|
|
182
|
+
* // create a new Animated Sprite
|
|
183
|
+
* var sprite = game.texture.createAnimationFromName([
|
|
184
|
+
* "walk0001.png", "walk0002.png", "walk0003.png",
|
|
185
|
+
* "walk0004.png", "walk0005.png", "walk0006.png",
|
|
186
|
+
* "walk0007.png", "walk0008.png", "walk0009.png",
|
|
187
|
+
* "walk0010.png", "walk0011.png"
|
|
188
|
+
* ]);
|
|
189
|
+
*
|
|
190
|
+
* // define an additional basic walking animation
|
|
191
|
+
* sprite.addAnimation ("simple_walk", [0,2,1]);
|
|
192
|
+
* // you can also use frame name to define your animation
|
|
193
|
+
* sprite.addAnimation ("speed_walk", ["walk0007.png", "walk0008.png", "walk0009.png", "walk0010.png"]);
|
|
194
|
+
* // set the default animation
|
|
195
|
+
* sprite.setCurrentAnimation("simple_walk");
|
|
196
|
+
* // set the renderable position to bottom center
|
|
197
|
+
* sprite.anchorPoint.set(0.5, 1.0);
|
|
198
|
+
*/
|
|
199
|
+
createAnimationFromName(names: string[] | number[], settings?: object | undefined): Sprite;
|
|
200
|
+
}
|
|
201
|
+
import Sprite from "./../../renderable/sprite.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default TextureCache;
|
|
2
|
+
/**
|
|
3
|
+
* a basic texture cache object
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
declare class TextureCache {
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
constructor(max_size: any);
|
|
11
|
+
cache: ArrayMultimap<any, any>;
|
|
12
|
+
tinted: Map<any, any>;
|
|
13
|
+
units: Map<any, any>;
|
|
14
|
+
max_size: any;
|
|
15
|
+
/**
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
18
|
+
clear(): void;
|
|
19
|
+
length: number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
validate(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @ignore
|
|
26
|
+
*/
|
|
27
|
+
get(image: any, atlas: any): any;
|
|
28
|
+
/**
|
|
29
|
+
* @ignore
|
|
30
|
+
*/
|
|
31
|
+
delete(image: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
tint(src: any, color: any): any;
|
|
36
|
+
/**
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
set(image: any, texture: any): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @ignore
|
|
42
|
+
*/
|
|
43
|
+
getUnit(texture: any): any;
|
|
44
|
+
}
|
|
45
|
+
import { ArrayMultimap } from "@teppeis/multimaps";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export default CanvasTexture;
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Canvas Texture of the given size
|
|
4
|
+
*/
|
|
5
|
+
declare class CanvasTexture {
|
|
6
|
+
/**
|
|
7
|
+
* @param {number} width - the desired width of the canvas
|
|
8
|
+
* @param {number} height - the desired height of the canvas
|
|
9
|
+
* @param {object} attributes - The attributes to create both the canvas and context
|
|
10
|
+
* @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl", "webgl2")
|
|
11
|
+
* @param {boolean} [attributes.offscreenCanvas=false] - will create an offscreenCanvas if true instead of a standard canvas
|
|
12
|
+
* @param {boolean} [attributes.willReadFrequently=false] - Indicates whether or not a lot of read-back operations are planned
|
|
13
|
+
* @param {boolean} [attributes.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
14
|
+
*/
|
|
15
|
+
constructor(width: number, height: number, attributes?: {
|
|
16
|
+
context?: boolean | undefined;
|
|
17
|
+
offscreenCanvas?: boolean | undefined;
|
|
18
|
+
willReadFrequently?: boolean | undefined;
|
|
19
|
+
antiAlias?: boolean | undefined;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* the canvas created for this CanvasTexture
|
|
23
|
+
* @type {HTMLCanvasElement|OffscreenCanvas}
|
|
24
|
+
*/
|
|
25
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
26
|
+
/**
|
|
27
|
+
* the rendering context of this CanvasTexture
|
|
28
|
+
* @type {CanvasRenderingContext2D}
|
|
29
|
+
*/
|
|
30
|
+
context: CanvasRenderingContext2D;
|
|
31
|
+
/**
|
|
32
|
+
* @ignore
|
|
33
|
+
*/
|
|
34
|
+
onResetEvent(width: any, height: any): void;
|
|
35
|
+
/**
|
|
36
|
+
* Clears the content of the canvas texture
|
|
37
|
+
*/
|
|
38
|
+
clear(): void;
|
|
39
|
+
/**
|
|
40
|
+
* enable/disable image smoothing (scaling interpolation)
|
|
41
|
+
* @param {boolean} [enable=false]
|
|
42
|
+
*/
|
|
43
|
+
setAntiAlias(enable?: boolean | undefined): void;
|
|
44
|
+
/**
|
|
45
|
+
* Resizes the canvas texture to the given width and height.
|
|
46
|
+
* @param {number} width - the desired width
|
|
47
|
+
* @param {number} height - the desired height
|
|
48
|
+
*/
|
|
49
|
+
resize(width: number, height: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Returns an ImageData object representing the underlying pixel data for a specified portion of this canvas texture.
|
|
52
|
+
* (Note: when using getImageData(), it is highly recommended to use the `willReadFrequently` attribute when creatimg the corresponding canvas texture)
|
|
53
|
+
* @param {number} x - The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
54
|
+
* @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
|
|
55
|
+
* @param {number} width - The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left
|
|
56
|
+
* @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
|
|
57
|
+
* @return {ImageData} The ImageData extracted from this CanvasTexture.
|
|
58
|
+
*/
|
|
59
|
+
getImageData(x: number, y: number, width: number, height: number): ImageData;
|
|
60
|
+
/**
|
|
61
|
+
* @ignore
|
|
62
|
+
*/
|
|
63
|
+
destroy(): void;
|
|
64
|
+
public set width(arg: number);
|
|
65
|
+
/**
|
|
66
|
+
* The width of this canvas texture in pixels
|
|
67
|
+
* @public
|
|
68
|
+
* @type {number}
|
|
69
|
+
*/
|
|
70
|
+
public get width(): number;
|
|
71
|
+
public set height(arg: number);
|
|
72
|
+
/**
|
|
73
|
+
* The height of this canvas texture in pixels
|
|
74
|
+
* @public
|
|
75
|
+
* @type {number}
|
|
76
|
+
*/
|
|
77
|
+
public get height(): number;
|
|
78
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initialize the "video" system (create a canvas based on the given arguments, and the related renderer). <br>
|
|
3
|
+
* melonJS support various scaling mode, that can be enabled <u>once the scale option is set to <b>`auto`</b></u> : <br>
|
|
4
|
+
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
5
|
+
* <center><img src="images/scale-fit.png"/></center><br>
|
|
6
|
+
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
7
|
+
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
8
|
+
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
9
|
+
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
10
|
+
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
11
|
+
* <center><img src="images/scale-flex.png"/></center><br>
|
|
12
|
+
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
13
|
+
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
14
|
+
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
15
|
+
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
16
|
+
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
17
|
+
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
18
|
+
* @memberof video
|
|
19
|
+
* @param {number} width - The width of the canvas viewport
|
|
20
|
+
* @param {number} height - The height of the canvas viewport
|
|
21
|
+
* @param {object} [options] - The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
|
|
22
|
+
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
23
|
+
* @param {number|Renderer} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO), or a custom renderer class
|
|
24
|
+
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
25
|
+
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
26
|
+
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
27
|
+
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
28
|
+
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
29
|
+
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
30
|
+
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
31
|
+
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
32
|
+
* @example
|
|
33
|
+
* // init the video with a 640x480 canvas
|
|
34
|
+
* me.video.init(640, 480, {
|
|
35
|
+
* parent : "screen",
|
|
36
|
+
* renderer : me.video.AUTO,
|
|
37
|
+
* scale : "auto",
|
|
38
|
+
* scaleMethod : "fit"
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
41
|
+
export function init(width: number, height: number, options?: {
|
|
42
|
+
parent?: string | HTMLElement | undefined;
|
|
43
|
+
renderer?: number | Renderer;
|
|
44
|
+
scale?: string | number | undefined;
|
|
45
|
+
scaleMethod?: string | undefined;
|
|
46
|
+
preferWebGL1?: boolean | undefined;
|
|
47
|
+
powerPreference?: string | undefined;
|
|
48
|
+
transparent?: boolean | undefined;
|
|
49
|
+
antiAlias?: boolean | undefined;
|
|
50
|
+
consoleHeader?: boolean | undefined;
|
|
51
|
+
} | undefined): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Create and return a new Canvas element
|
|
54
|
+
* @memberof video
|
|
55
|
+
* @param {number} width - width
|
|
56
|
+
* @param {number} height - height
|
|
57
|
+
* @param {boolean} [returnOffscreenCanvas=false] - will return an OffscreenCanvas if supported
|
|
58
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
59
|
+
*/
|
|
60
|
+
export function createCanvas(width: number, height: number, returnOffscreenCanvas?: boolean | undefined): HTMLCanvasElement | OffscreenCanvas;
|
|
61
|
+
/**
|
|
62
|
+
* return a reference to the parent DOM element holding the main canvas
|
|
63
|
+
* @returns {HTMLElement}
|
|
64
|
+
*/
|
|
65
|
+
export function getParent(): HTMLElement;
|
|
66
|
+
/**
|
|
67
|
+
* @namespace video
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Select the HTML5 Canvas renderer
|
|
71
|
+
* @memberof video
|
|
72
|
+
* @constant
|
|
73
|
+
*/
|
|
74
|
+
export const CANVAS: 0;
|
|
75
|
+
/**
|
|
76
|
+
* Select the WebGL renderer
|
|
77
|
+
* @memberof video
|
|
78
|
+
* @constant
|
|
79
|
+
*/
|
|
80
|
+
export const WEBGL: 1;
|
|
81
|
+
/**
|
|
82
|
+
* Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
|
|
83
|
+
* @memberof video
|
|
84
|
+
* @constant
|
|
85
|
+
*/
|
|
86
|
+
export const AUTO: 2;
|
|
87
|
+
/**
|
|
88
|
+
* A reference to the active Canvas or WebGL active renderer renderer
|
|
89
|
+
* @memberof video
|
|
90
|
+
* @type {CanvasRenderer|WebGLRenderer}
|
|
91
|
+
*/
|
|
92
|
+
export let renderer: CanvasRenderer | WebGLRenderer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a Vertex Buffer object
|
|
4
|
+
* @class VertexArrayBuffer
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export default class VertexArrayBuffer {
|
|
8
|
+
constructor(vertex_size: any, vertex_per_quad: any);
|
|
9
|
+
vertexSize: any;
|
|
10
|
+
quadSize: any;
|
|
11
|
+
maxVertex: number;
|
|
12
|
+
vertexCount: number;
|
|
13
|
+
buffer: ArrayBuffer;
|
|
14
|
+
bufferF32: Float32Array;
|
|
15
|
+
bufferU32: Uint32Array;
|
|
16
|
+
/**
|
|
17
|
+
* clear the vertex array buffer
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
clear(): void;
|
|
21
|
+
/**
|
|
22
|
+
* return true if full
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
isFull(vertex?: any): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* resize the vertex buffer, retaining its original contents
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
resize(): VertexArrayBuffer;
|
|
31
|
+
/**
|
|
32
|
+
* push a new vertex to the buffer
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
push(x: any, y: any, u: any, v: any, tint: any): VertexArrayBuffer;
|
|
36
|
+
/**
|
|
37
|
+
* return a reference to the data in Float32 format
|
|
38
|
+
* @ignore
|
|
39
|
+
*/
|
|
40
|
+
toFloat32(begin: any, end: any): Float32Array;
|
|
41
|
+
/**
|
|
42
|
+
* return a reference to the data in Uint32 format
|
|
43
|
+
* @ignore
|
|
44
|
+
*/
|
|
45
|
+
toUint32(begin: any, end: any): Uint32Array;
|
|
46
|
+
/**
|
|
47
|
+
* return the size of the vertex in vertex
|
|
48
|
+
* @ignore
|
|
49
|
+
*/
|
|
50
|
+
length(): number;
|
|
51
|
+
/**
|
|
52
|
+
* return true if empty
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
isEmpty(): boolean;
|
|
56
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a base GL Shader object
|
|
4
|
+
*/
|
|
5
|
+
export default class GLShader {
|
|
6
|
+
/**
|
|
7
|
+
* @param {WebGLRenderingContext} gl - the current WebGL rendering context
|
|
8
|
+
* @param {string} vertex - a string containing the GLSL source code to set
|
|
9
|
+
* @param {string} fragment - a string containing the GLSL source code to set
|
|
10
|
+
* @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp').
|
|
11
|
+
* @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
|
|
12
|
+
* @example
|
|
13
|
+
* // create a basic shader
|
|
14
|
+
* var myShader = new me.GLShader(
|
|
15
|
+
* // WebGL rendering context
|
|
16
|
+
* gl,
|
|
17
|
+
* // vertex shader
|
|
18
|
+
* [
|
|
19
|
+
* "void main() {",
|
|
20
|
+
* " gl_Position = doMathToMakeClipspaceCoordinates;",
|
|
21
|
+
* "}"
|
|
22
|
+
* ].join("\n"),
|
|
23
|
+
* // fragment shader
|
|
24
|
+
* [
|
|
25
|
+
* "void main() {",
|
|
26
|
+
* " gl_FragColor = doMathToMakeAColor;",
|
|
27
|
+
* "}"
|
|
28
|
+
* ].join("\n")
|
|
29
|
+
* )
|
|
30
|
+
* // use the shader
|
|
31
|
+
* myShader.bind();
|
|
32
|
+
*/
|
|
33
|
+
constructor(gl: WebGLRenderingContext, vertex: string, fragment: string, precision?: string | undefined);
|
|
34
|
+
/**
|
|
35
|
+
* the active gl rendering context
|
|
36
|
+
* @type {WebGLRenderingContext}
|
|
37
|
+
*/
|
|
38
|
+
gl: WebGLRenderingContext;
|
|
39
|
+
/**
|
|
40
|
+
* the vertex shader source code
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
vertex: string;
|
|
44
|
+
/**
|
|
45
|
+
* the fragment shader source code
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
fragment: string;
|
|
49
|
+
/**
|
|
50
|
+
* the location attributes of the shader
|
|
51
|
+
* @type {GLint[]}
|
|
52
|
+
*/
|
|
53
|
+
attributes: GLint[];
|
|
54
|
+
/**
|
|
55
|
+
* a reference to the shader program (once compiled)
|
|
56
|
+
* @type {WebGLProgram}
|
|
57
|
+
*/
|
|
58
|
+
program: WebGLProgram;
|
|
59
|
+
/**
|
|
60
|
+
* the uniforms of the shader
|
|
61
|
+
* @type {object}
|
|
62
|
+
*/
|
|
63
|
+
uniforms: object;
|
|
64
|
+
/**
|
|
65
|
+
* Installs this shader program as part of current rendering state
|
|
66
|
+
*/
|
|
67
|
+
bind(): void;
|
|
68
|
+
/**
|
|
69
|
+
* returns the location of an attribute variable in this shader program
|
|
70
|
+
* @param {string} name - the name of the attribute variable whose location to get.
|
|
71
|
+
* @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
|
|
72
|
+
*/
|
|
73
|
+
getAttribLocation(name: string): GLint;
|
|
74
|
+
/**
|
|
75
|
+
* Set the uniform to the given value
|
|
76
|
+
* @param {string} name - the uniform name
|
|
77
|
+
* @param {object|Float32Array} value - the value to assign to that uniform
|
|
78
|
+
* @example
|
|
79
|
+
* myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
|
|
80
|
+
*/
|
|
81
|
+
setUniform(name: string, value: object | Float32Array): void;
|
|
82
|
+
/**
|
|
83
|
+
* activate the given vertex attribute for this shader
|
|
84
|
+
* @param {WebGLRenderingContext} gl - the current WebGL rendering context
|
|
85
|
+
* @param {object[]} attributes - an array of vertex attributes
|
|
86
|
+
* @param {number} vertexByteSize - the size of a single vertex in bytes
|
|
87
|
+
*/
|
|
88
|
+
setVertexAttributes(gl: WebGLRenderingContext, attributes: object[], vertexByteSize: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* destroy this shader objects resources (program, attributes, uniforms)
|
|
91
|
+
*/
|
|
92
|
+
destroy(): void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* set precision for the fiven shader source
|
|
3
|
+
* won't do anything if the precision is already specified
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export function setPrecision(src: any, precision: any): any;
|
|
7
|
+
/**
|
|
8
|
+
* return the highest precision format supported by this device for GL Shaders
|
|
9
|
+
* @ignore
|
|
10
|
+
* @param {WebGLRenderingContext} gl
|
|
11
|
+
* @returns {boolean} "lowp", "mediump", or "highp"
|
|
12
|
+
*/
|
|
13
|
+
export function getMaxShaderPrecision(gl: WebGLRenderingContext): boolean;
|