melonJS
    Preparing search index...

    Type Alias ApplicationSettings

    ApplicationSettings: {
        antiAlias: boolean;
        backgroundColor: string;
        batcher?: new (renderer: any) => Batcher;
        blendMode: BlendMode;
        cameraClass?: new (
            minX: number,
            minY: number,
            maxX: number,
            maxY: number,
        ) => Camera2d;
        compositor?: new (renderer: any) => Batcher;
        consoleHeader: boolean;
        failIfMajorPerformanceCaveat: boolean;
        gpuTilemap: boolean;
        highPrecisionShader: boolean;
        legacy: boolean;
        physic: PhysicsType;
        powerPreference: PowerPreference;
        renderer: RendererType | Renderer;
        scale: number | "auto";
        scaleMethod: ScaleMethod;
        scaleTarget: HTMLElement;
        subPixel: boolean;
        textureFilter: "auto" | "nearest" | "linear";
        transparent: boolean;
        verbose: boolean;
    } & (
        | { canvas?: never; parent: string
        | HTMLElement }
        | { canvas: HTMLCanvasElement; parent?: never }
    )

    Type Declaration

    • antiAlias: boolean

      whether to enable or not video scaling interpolation

      false
      
    • backgroundColor: string

      the CSS background color of the parent element that holds the canvas. Applied during initialization to prevent a white flash before the first render. Set to "transparent" to disable, or any valid CSS color value.

      "#000000"
      
    • Optionalbatcher?: new (renderer: any) => Batcher

      a custom batcher class (WebGL only)

    • blendMode: BlendMode

      the default blend mode to use ("normal", "multiply", "lighter", "additive", "screen")

      "normal"
      
    • OptionalcameraClass?: new (minX: number, minY: number, maxX: number, maxY: number) => Camera2d

      Default camera class instantiated for any Stage that does not explicitly provide its own cameras. Set to Camera3d to opt every stage in the app into perspective rendering by default. Stages can still override per-instance via super({ cameras: [...] }) or per-class via super({ cameraClass: Camera2d }). Built-in stages (e.g. the loader screen) explicitly use Camera2d regardless of this setting.

      WebGL requirement. Camera classes whose static defaultSortOn === "depth" (Camera3d and any subclass) need the WebGL renderer — perspective projection, depth attachment and mesh draw all live in the WebGL backend. Pairing such a cameraClass with renderer: video.AUTO on a system where AUTO falls back to Canvas emits a console.warn at construction time and produces a non-functional render. Use renderer: video.WEBGL to get a hard throw instead.

      Camera2d
      
    • Optionalcompositor?: new (renderer: any) => Batcher

      a custom batcher class (WebGL only)

      since 18.1.0 — use batcher instead

    • consoleHeader: boolean

      whether to display melonJS version and basic device information in the console

      true
      
    • failIfMajorPerformanceCaveat: boolean

      If true, treat WebGL as unavailable when the browser warns that a context would perform dramatically worse than a native application (a software rasterizer, a blocklisted driver). Note this is stricter than the WebGL default, which is false.

      Combined with the WebGL 2 requirement, the effect is: under AUTO such a machine gets the Canvas renderer, and under WEBGL construction throws. Set to false to accept a software or blocklisted WebGL context instead.

      true
      
    • gpuTilemap: boolean

      Enable the WebGL2 procedural shader path for orthogonal tile layers. When true (default), eligible layers render via a single quad per tileset + a fragment shader doing per-fragment GID lookup, bypassing the per-tile draw loop entirely. Layers that don't qualify (Canvas renderer, non-orthogonal, collection-of-image tilesets, tilerendersize "grid", non-zero tileoffset, oversampled beyond the shader's overflow window) fall back to the legacy path automatically. Set to false to disable globally.

      true
      
    • highPrecisionShader: boolean

      enable high precision shaders (WebGL only). When false, shaders prefer "mediump" precision for better performance on some mobile GPUs, falling back to "lowp" if "mediump" is not supported. When true (default), the highest precision supported by the device is used. This setting is ignored by the Canvas renderer.

      true
      
      import { Application, device } from "melonjs";
      const app = new Application(800, 600, {
      parent: "screen",
      // prefer lower shader precision on mobile for better performance
      highPrecisionShader: !device.isMobile,
      });
    • legacy: boolean

      whether to enable legacy mode (enables deprecated video.init() entry point)

      false
      
    • physic: PhysicsType

      The physics system to use. Accepts:

      • "builtin" (default) — the built-in SAT physics adapter
      • "none" — disables physics; World.step skips the simulation, the world container behaves like a pure scene graph
      • a PhysicsAdapter instance — e.g. new MatterAdapter() from @melonjs/matter-adapter, or any third-party adapter
      • { adapter: PhysicsAdapter } — explicit form, reserved for future per-app physics options

      The adapter's physicLabel becomes world.physic so user code can branch on the active engine without importing the concrete adapter class (app.world.physic === "matter", etc.).

      "builtin"
      
    • powerPreference: PowerPreference

      A hint to the user agent about which GPU to use on multi-GPU systems (discrete vs integrated). Browsers generally favour the low-power GPU unless asked otherwise, to preserve battery life.

      • "default" — no hint; let the user agent decide.
      • "low-power" — prefer the integrated GPU.
      • "high-performance" — prefer the discrete GPU. Note that browsers only honour this for pages that handle context loss, since switching GPU can drop the context; melonJS registers those handlers itself, so the request is respected.

      The same hint (and the same values, minus "default") is used by WebGPU's adapter request, so this setting is backend-neutral.

      "default"
      
    • renderer: RendererType | Renderer

      Renderer to use. Three built-in modes (constants from me.video):

      • CANVAS — HTML5 Canvas backend. No shader / mesh / Camera3d support.
      • WEBGLrequires WebGL 2 (the WebGL renderer is WebGL 2 only since 20.0). Throws at new Application(...) time if a WebGL 2 context is unavailable (WebGL-1-only device, driver-blocklisted GPU, perf-caveat failure, etc.). Use this when your scene needs Camera3d, Mesh, ShaderEffect, Light2d or GPU tilemap — you'd rather fail fast than render a stuck blank canvas.
      • AUTO — try WebGL 2, silently fall back to Canvas if unavailable. Application construction always succeeds. The WebGL-only subsystems (Camera3d, Mesh, ShaderEffect, Light2d, GPU tilemap) silently stop working under the Canvas fallback — if your scene depends on any of those, use WEBGL instead.

      Or pass a custom Renderer subclass instance for full control.

      AUTO
      
    • scale: number | "auto"

      enable scaling of the canvas ('auto' for automatic scaling)

      1
      
    • scaleMethod: ScaleMethod

      screen scaling modes

      "manual"
      
    • scaleTarget: HTMLElement

      the HTML Element to be used as the reference target when using automatic scaling (by default melonJS will use the parent container of the div element containing the canvas)

    • subPixel: boolean

      whether to enable sub-pixel rendering (avoid sprite flickering when using transforms)

      false
      
    • textureFilter: "auto" | "nearest" | "linear"

      Default texture magnification/minification filter, decoupled from antiAlias (WebGL only — the 2D Canvas renderer has no per-texture filtering and ignores this).

      antiAlias conflates two separate concerns: polygon-edge antialiasing (MSAA) and texture sampling smoothness. This setting separates the texture half out, so you can choose them independently — e.g. smooth textures with no MSAA, or crisp pixel-art textures with MSAA edges.

      • "auto" (default) — follow antiAlias (linear when true, nearest when false): unchanged behavior.
      • "nearest" — crisp/pixelated upscaling, regardless of antiAlias.
      • "linear" — smooth, regardless of antiAlias.

      This is the default for every texture; a Mesh can still override it per-mesh via its own textureFilter setting (which wins).

      "auto"
      
      // smooth textures but NO polygon-edge MSAA
      const app = new Application(1024, 768, {
      renderer: video.WEBGL,
      antiAlias: false, // MSAA off
      textureFilter: "linear", // textures still filtered smooth
      });

      // crisp pixel-art textures WITH MSAA-smoothed edges
      new Application(1024, 768, {
      renderer: video.WEBGL,
      antiAlias: true, // MSAA on
      textureFilter: "nearest", // textures stay crisp
      });
    • transparent: boolean

      whether to allow transparent pixels in the front buffer (screen).

      false
      
    • verbose: boolean

      whether to enable verbose mode (additional console output for debugging)

      false
      
    • { canvas?: never; parent: string | HTMLElement }
      • Optionalcanvas?: never
      • parent: string | HTMLElement

        the DOM parent element (or its string ID) to hold the canvas in the HTML file

    • { canvas: HTMLCanvasElement; parent?: never }
      • canvas: HTMLCanvasElement

        an existing canvas element to use as the renderer target (by default melonJS will create its own canvas based on given parameters)

      • Optionalparent?: never