Engine API Reference - v2.21.0-beta.6
    Preparing search index...

    Interface ResourceParser

    interface ResourceParser {
        canParse: (context: ParserContext) => boolean;
        handler?: ResourceHandler;
        load: (
            url: string | { load: string; original: string },
            callback: ResourceHandlerCallback,
            asset?: Asset,
        ) => void;
        open?: (url: string, data: any, asset?: Asset) => any;
    }
    Index

    Properties

    canParse: (context: ParserContext) => boolean

    Returns true if this parser can handle the described resource. Parsers are consulted newest-first; the first to return true is used.

    handler?: ResourceHandler

    Assigned by the owning handler on registration; available in load/open (for example this.handler.fetch(...)).

    load: (
        url: string | { load: string; original: string },
        callback: ResourceHandlerCallback,
        asset?: Asset,
    ) => void

    Fetches (typically via this.handler.fetch) and produces the resource, then invokes the callback.

    open?: (url: string, data: any, asset?: Asset) => any

    Optional. Called by the default ResourceHandler#open when parsers are registered. Handlers that override open may call it with an extended signature - for example the texture handler calls open(url, data, device, textureOptions) on its parsers.