melonJS
    Preparing search index...

    Interface Asset

    interface Asset {
        autoplay?: boolean;
        data?: string | object | { glsl?: string; wgsl?: string };
        loop?: boolean;
        name: string;
        src?: string | string[];
        stream?: boolean;
        type: string;
    }
    Index
    autoplay?: boolean

    audio and video: start playing once loaded, or once added to a scene (a browser may require a user interaction first)

    data?: string | object | { glsl?: string; wgsl?: string }

    inline content in place of a src: the parsed JSON map or tileset (an object) for "tmx" / "tilemap" / "spritefusion" / "tsx", the parsed project for "ldtk" (one that keeps its levels in the project file), the GLSL source of an effect body for "shader", or a {glsl, wgsl} pair of them so that one asset serves both backends (either half may be omitted). A type registered with loader.setParser reads what its parser expects there

    loop?: boolean

    audio and video: loop when playing

    name: string

    the name the asset is kept and read back under (loader.getImage(name), new Sprite(x, y, { image: name }), level.load(name), audio.play(name))

    src?: string | string[]

    the URL of the file, relative to the page or to the type's base URL (setBaseURL), or a data URI. For "audio" it is the directory holding the clip: the loader appends the asset name and each extension given to audio.init(), and keeps the first that decodes. For "image" it may be an array of sources, tried in order until one loads: a fallback chain, such as compressed texture formats by priority with a PNG last. For "shader" it may be an object of URLs instead (see the example).

    stream?: boolean

    audio and video: start playing before the whole file is downloaded, rather than waiting for it

    type: string

    the type of the asset, which picks its parser. The types, the files each takes, and how the asset is read back:

    type loads files read back with
    "image" an image, or a compressed texture .png, .jpg, .webp, .gif, .svg, a data URI; compressed: .ktx, .ktx2, .dds, .pvr, .pkm image: name on a renderable, getImage
    "aseprite" an Aseprite file: its frames as one image, and their description .aseprite as an "image" and a "json" of that name
    "json" JSON data: a texture atlas, collision shapes, your own .json getJSON
    "binary" a file's content as it is: a bitmap font's .fnt, a tracker tune any getBinary
    "js" a script, run once loaded .js nothing is kept
    "audio" a sound or a music a directory: the name and the extensions given to audio.init() are added audio.play(name)
    "video" a video .mp4, .webm, what the browser plays getVideo
    "fontface" a web font .woff2, .woff, .ttf its name, as a CSS font family; getFont
    "shader" a shader: an effect body, or a whole program GLSL and WGSL sources, or inline data getShader
    "tmx" a Tiled map .tmx, .xml (XML); .tmj, .json (JSON) level.load(name), getTileMap
    "tsx" a Tiled tileset kept in a file of its own .tsx, .xml (XML); .tsj, .json (JSON) by the maps that name it; getTileMap
    "tilemap" a tile map, whatever tool wrote it: "tmx" under a name that is not an editor's the same as "tmx" level.load(name), getTileMap
    "spritefusion" a Sprite Fusion map, with the spritesheet.png saved next to it map.json, map.tmx level.load(name), getTileMap
    "ldtk" an LDtk project, with the level files and the images it names .ldtk (and its .ldtkl) level.load("name:Level"), level.load("name"), getLDtk
    "obj" a Wavefront model .obj getOBJ
    "mtl" a Wavefront material library .mtl getMTL
    "gltf", "glb" a glTF scene .gltf, .glb level.load(name), getGLTF

    Any other type is one registered with loader.setParser.

    The three tile map types share one parser: they differ only in name, and in "spritefusion" loading the map's spritesheet with it. The extension of the file says whether a map is XML or JSON (.tmj and .tsj are extensions, not asset types), and a Sprite Fusion map.json is read under any of the three.