Engine API Reference - v2.7.1
    Preparing search index...

    Class WasmModule

    A pure static utility class which supports immediate and lazy loading of WebAssembly modules. Note that you can load WebAssembly modules even before instantiating your AppBase instance.

    This class is generally only needed if you are developing against the Engine directly. Editor projects automatically load WebAssembly modules included in the project's assets.

    Do not use this class to load the Basis WebAssembly module. Instead, please refer to basisInitialize.

    // Load the Ammo.js physics engine
    pc.WasmModule.setConfig('Ammo', {
    glueUrl: `ammo.wasm.js`,
    wasmUrl: `ammo.wasm.wasm`,
    fallbackUrl: `ammo.js`
    });
    await new Promise((resolve) => {
    pc.WasmModule.getInstance('Ammo', () => resolve());
    });
    Index

    Methods

    • Get a wasm module's configuration.

      Parameters

      • moduleName: string

        Name of the module.

      Returns any

      The previously set configuration.

    • Get a wasm module instance. The instance will be created if necessary and returned in the second parameter to callback.

      Parameters

      • moduleName: string

        Name of the module.

      • callback: ModuleInstanceCallback

        The function called when the instance is available.

      Returns void

    • Set a wasm module's configuration.

      Parameters

      • moduleName: string

        Name of the module.

      • Optionalconfig: {
            errorHandler?: ModuleErrorCallback;
            fallbackUrl?: string;
            glueUrl?: string;
            numWorkers?: number;
            wasmUrl?: string;
        }

        The configuration object.

        • OptionalerrorHandler?: ModuleErrorCallback

          Function to be called if the module fails to download.

        • OptionalfallbackUrl?: string

          URL of the fallback script to use when wasm modules aren't supported.

        • OptionalglueUrl?: string

          URL of glue script.

        • OptionalnumWorkers?: number

          For modules running on worker threads, the number of threads to use. Default value is based on module implementation.

        • OptionalwasmUrl?: string

          URL of the wasm script.

      Returns void