Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

melonJS

> 前端框架
Open source

a modern & lightweight HTML5 game engine

6.3K stars0 likes3 views
WebsiteGitHub

About

a modern & lightweight HTML5 game engine

melonJS 2

A modern & fully featured HTML5 game engine

melonJS is an open-source 2.5D game engine designed for indie developers — perspective and orthogonal cameras, GPU-accelerated tilemap rendering, post-processing effects, custom shaders, 3D mesh support, polygon-accurate physics, modern Tiled workflows, and high performance. Runs on WebGPU, WebGL 2 or Canvas2D with automatic fallback. The whole engine is ~250 KB minzipped of vanilla JS/TS, with no dependencies and no toolchain lock-in. Built with modern class syntax and bundled with esbuild.

melonJS is licensed under the MIT License and actively maintained by the team at AltByte in Singapore.

Why melonJS

melonJS is designed so you can focus on making games, not on graphics plumbing.

  • Canvas2D-inspired rendering API — If you've used the HTML5 Canvas, you already know melonJS. The rendering API (save, restore, translate, rotate, setColor, fillRect, ...) follows the same familiar patterns — no render graphs, no shader pipelines, no instruction sets to learn.

  • True renderer abstraction — Write your game once, run it on WebGPU, WebGL 2 or Canvas2D with zero code changes. The engine handles all GPU complexity behind a unified API: the default AUTO mode tries WebGPU first at startup, falls back to WebGL 2 if that is unavailable, and ultimately to Canvas, and the entire feature set renders identically on both GPU backends.

  • Complete engine, minimal footprint — Physics, tilemaps, audio, input, cameras, tweens, particles, UI — a full game stack in a single tree-shakeable ES module. No dependency sprawl, no library stitching.

  • Scenes, loaded in one call — level.load(name) brings an authored scene straight into your world. Tiled is a first-class citizen for 2D — orthogonal, isometric, hexagonal & staggered maps, animated tilesets, collision shapes, object properties, compressed formats, with GPU-accelerated tile rendering on the GPU backends — and glTF / GLB is the equivalent for 3D scenes: author in Blender (or any DCC tool), export a .glb, and the whole scene — meshes, materials, cameras, lights, and node animation — loads under a Camera3d, no per-mesh wiring. Animated models play back through the same animation API as a 2D Sprite.

  • Batteries included, hackable by design — Get started in minutes with minimal setup. When you need to go deeper: modern class-based architecture, a plugin system for engine extensions, and a clean architecture that's easy to extend without fighting the framework.

About melonJS

melonJS is a fully featured game engine :

Compatibility

  • Standalone library (does not rely on anything else, except a HTML5 capable browser)
  • Compatible with all major browsers (Chrome, Safari, Firefox, Opera, Edge) and mobile devices

Graphics

  • Fast GPU renderers (WebGPU and WebGL 2) for desktop and mobile devices, with fallback to Canvas rendering
  • Since 20.0 the aging WebGL 1 path is retired and WebGL 2 is the baseline; devices offering only WebGL 1 fall back to the Canvas renderer under AUTO
  • Extensible batcher system for custom rendering pipelines, with backend-neutral vertex formats and draw topologies (declare a layout once, describe it to either GPU backend)
  • High DPI resolution & Canvas advanced auto scaling
  • Sprite with 9-slice scaling option and frame animation
  • Built-in effects such as tinting, masking, and the full set of CSS-style blend modes (normal, none, additive, multiply, screen, exclusion, darken, lighten, overlay, hard-light, color-dodge, color-burn, soft-light, difference) — all of them supported identically on WebGPU, WebGL 2 and Canvas since 20.2
  • Standard spritesheet, single and multiple Packed Textures support
  • Compressed texture support (DDS, KTX, KTX2, PVR, PKM) with automatic format detection and fallback
  • Hardware antialiasing (antiAlias: true) on both GPU backends — and it survives post-processing, since the offscreen targets a post-effect chain renders into are multisampled to match
  • Procedural noise textures: Noise (simplex/perlin/value/cellular, fBm / ridged / ping-pong fractal, domain warp; renderer-free and CPU-samplable for heightmaps, terrain, and spawn jitter) and NoiseTexture2d — bake a noise field into a sprite image, a Gradient color ramp, or a live-animated tangent-space normal map for lit water and surfaces; unified under a new Texture2d base alongside TextureAtlas
  • 3D mesh rendering with OBJ/MTL model loading, multi-material support, hardware depth testing, and perspective projection via Camera3d — retained-mode geometry, uploaded to the GPU once and re-drawn from there, so moving, rotating, scaling or re-tinting a mesh costs no vertex upload and no per-vertex CPU work at all
  • Mipmapped and anisotropically-filtered mesh textures on both GPU backends, so distant and grazing-angle geometry stops shimmering (opt out per mesh with textureFilter: "nearest" for crisp pixel-art models)
  • Lighting, in 2D and 3D:
    • 2D — Light2d as a first-class Renderable (multiple dynamic lights, radial-gradient falloff, illumination-only mode, procedural rendering via drawLight), plus optional per-pixel normal-map shading on sprites for 3D-looking dynamic lights
    • 3D — Light3d directional, point, spot and ambient lights, added to the world like Light2d (half-Lambert diffuse + ambient fill, quadratic falloff and cone angles on the punctual types, runtime-manipulable for day/night), auto-loaded from a glTF scene's authored suns and lamps
    • up to 32 simultaneous lights on either path, with light data travelling in a uniform buffer — a static light rig costs zero GPU state changes per frame
  • Ground ("blob") shadows for 3D objects — on by default — so characters and props read as standing on the floor instead of hovering. An ellipse matching the caster's own footprint and rotation, shrinking and fading with height above the ground; one extra draw per object, and one for an entire InstancedMesh scatter regardless of instance count. Controllable per object, per glTF scene (level.load(name, { castGroundShadow })) or application-wide. Deliberately not shadow mapping: it answers "where is this standing", which is what a 2.5D scene needs
  • Built-in shader effects (Flash, Outline, Glow, Dissolve, CRT, Hologram, etc.) with multi-pass chaining via addPostEffect(), plus custom shader support on both GPU backends: ShaderEffect for per-sprite fragment effects (GLSL and/or WGSL bodies) and complete custom mesh shader programs via mesh.shader (a dual-language GLShader: GLSL pair and/or WGSL module)
  • Trail renderable for fading, tapering ribbons behind moving objects (speed lines, sword slashes, magic trails)
  • System & Bitmap Text with built-in typewriter effect
  • Video sprite playback

Sound

  • Web Audio support with 3D spatial audio and stereo panning based on Howler
  • Built-in procedural audio primitives (envelope-shaped oscillators, white/pink/brown noise) for SFX without sample assets
  • Direct AudioContext / master-gain accessors for custom WebAudio graphs that mix with the engine's master volume / mute

Physics

  • Polygon (SAT) based collision algorithm for accurate detection and response
  • Fast broad-phase collision detection using spatial partitioning (QuadTree in 2D, Octree in 3D, swapped automatically)
  • Raycast, AABB and sphere region queries with precise entry geometry, including 3D raycasts (raycast3d)
  • Collision lifecycle hooks on every Renderable
  • Collision filtering for optimized automatic collision detection
  • Multiple shapes per body for complex hitboxes
  • Pluggable PhysicsAdapter interface for custom physics via official adapters

Input

  • Mouse and Touch device support (with mouse emulation)
  • Gamepad support with button and axes binding
  • Keyboard event handling with key binding system
  • Device motion & accelerometer support

Camera

  • Multi-camera support (split-screen, minimaps, multiple viewports)
  • Optional perspective camera (Camera3d) with frustum culling for 2.5D / 3D-projected scenes — drop-in subclass of the default 2D camera
  • Camera follow with configurable deadzone and frame-rate-independent damping
  • Built-in shake, fade, flash, and mask-based transition effects
  • Per-camera post-processing pipeline with stackable shader effects and color grading (ColorMatrix)

UI

  • UIBaseElement / UISpriteElement containers for clickable, hoverable and holdable elements with full pointer-event wiring
  • Draggable / DropTarget for drag-and-drop with configurable overlap or contains-check
  • UITextButton text button with hover, press, and key-bind support — built on BitmapText

Scenes

  • Load a scene in one call with level.load(name) — 2D Tiled maps and 3D glTF scenes alike, auto-registered on preload
  • Tiled map format up to 1.12 built-in support for easy level design
    • GPU-accelerated tile rendering for orthogonal maps on the GPU backends (WebGL 2 and WebGPU) — each layer draws as a single quad with no per-tile loop, ~5–8× faster than the legacy CPU renderer on dense maps. Honors animated tiles, flip bits, per-layer opacity/tint/blend, and oversized bottom-aligned tiles; falls back transparently to the CPU renderer on isometric/staggered/hexagonal layers or under the Canvas renderer
    • Uncompressed and compressed Plain, Base64, CSV and JSON encoded XML tilemap loading
    • Orthogonal, Isometric, Hexagonal (both normal and staggered) and Oblique maps
    • Multiple layers with per-layer alpha, tinting and blend modes (multiple background/foreground, collision and Image layers)
    • Parallax scrolling via Image layers, with parallax origin support
    • Animated and multiple Tileset support, tile sub-rectangles, embedded base64 images
    • Native .aseprite / .ase tileset images (Tiled 1.11+ qaseprite plugin workflow), with frame tags auto-mapped to per-tile animations — no PNG export step required
    • Tileset transparency settings
    • Rectangle, Ellipse, Polygon, Polyline and Capsule (round-rect) object shapes
    • Tiled Objects with custom properties (string, number, boolean, color, file, object, list/array and class-typed)
    • Per-object opacity and visibility
    • Concave collision polygons auto-decomposed via earcut triangulation
    • Flipped & rotated Tiles
    • Dynamic Layer and Object/Group ordering
    • Dynamic Entity loading via an extensible object factory registry — register custom handlers for any Tiled class name without modifying engine code
    • Shape based Tile collision support
  • glTF / GLB 3D scenes — load an authored 3D scene with level.load(...), the same one call as a Tiled map
    • The whole scene loads at once — meshes, materials, cameras and lights — viewed under a Camera3d
    • Automatically lit by the scene's authored lights — the sun plus any point/spot lamps set up in the authoring tool, each keeping its authored name so getChildByName("Sun") finds it for runtime tuning
    • Textured, solid-colored, and vertex-colored materials
    • Node animation — walk/idle/sprint characters, spinning pickups, doors, lifts — played through the same setCurrentAnimation / play / pause / stop API as a 2D Sprite
    • .glb and .gltf files, with embedded or external buffers & textures
    • Works with any glTF authoring tool (Blend

Issues· 19 open

View all issuesOpen on GitHub
  • #1688

    Pool: retire the legacy name-keyed object pool from engine internals

    Updated Sep 20, 2026
  • #1656

    Loader: named asset bundles, so a level's assets can be loaded and freed as one unit

    Updated Sep 16, 2026
  • #1655

    Container: opt-in texture caching for a static subtree, so it costs one quad instead of N draws

    Updated Sep 8, 2026
  • #1631

    Ground shadows: shape and placement controls (scale, offset, light direction)

    Updated Aug 31, 2026
  • #1383

    Add textured ribbon mode to Trail renderable

    Updated Aug 30, 2026
  • #1621

    Trail: 3D points, so a ribbon can recede under a Camera3d

    Updated Aug 30, 2026
  • #1407

    Per-sprite multi-pass effects use canvas-relative UVs instead of sprite-local UVs

    FeatureUpdated Aug 30, 2026
  • #1522

    Per-glyph effect hook for BitmapText (batched vertex offset + tint)

    Updated Aug 30, 2026
  • #1616

    Tree-shaking: importing a single symbol costs 184 kB gzip

    Updated Aug 29, 2026
  • #1510

    Types: reconcile the 2D/3D position vector split across Renderable and the shape chain

    ImprovementUpdated Aug 28, 2026

> Tags

JavaScript2d-game-enginecanvas2dcontributions-welcomees6

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 25, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架