API

Interface ISceneLoaderPluginAsync

Interface used to define an async SceneLoader plugin

interface ISceneLoaderPluginAsync {
    extensions: string | ISceneLoaderPluginExtensions;
    name: string;
    canDirectLoad?(data: string): boolean;
    directLoad?(scene: Scene, data: string): unknown;
    importMeshAsync(
        meshesNames: string | readonly string[] | null | undefined,
        scene: Scene,
        data: unknown,
        rootUrl: string,
        onProgress?: (event: ISceneLoaderProgressEvent) => void,
        fileName?: string,
    ): Promise<ISceneLoaderAsyncResult>;
    loadAssetContainerAsync(
        scene: Scene,
        data: unknown,
        rootUrl: string,
        onProgress?: (event: ISceneLoaderProgressEvent) => void,
        fileName?: string,
    ): Promise<AssetContainer>;
    loadAsync(
        scene: Scene,
        data: unknown,
        rootUrl: string,
        onProgress?: (event: ISceneLoaderProgressEvent) => void,
        fileName?: string,
    ): Promise<void>;
    loadFile?(
        scene: Scene,
        fileOrUrl: string | ArrayBufferView<ArrayBufferLike> | File,
        rootUrl: string,
        onSuccess: (data: unknown, responseURL?: string) => void,
        onProgress?: (ev: ISceneLoaderProgressEvent) => void,
        useArrayBuffer?: boolean,
        onError?: (request?: WebRequest, exception?: LoadFileError) => void,
        name?: string,
    ): Nullable<IFileRequest>;
    rewriteRootURL?(rootUrl: string, responseURL?: string): string;
}

Hierarchy (View Summary)

Index
extensions: string | ISceneLoaderPluginExtensions

The file extensions supported by the plugin.

name: string

The friendly name of the plugin.

  • Import meshes into a scene.

    Parameters

    • meshesNames: string | readonly string[] | null | undefined

      An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported

    • scene: Scene

      The scene to import into

    • data: unknown

      The data to import

    • rootUrl: string

      The root url for scene and resources

    • OptionalonProgress: (event: ISceneLoaderProgressEvent) => void

      The callback when the load progresses

    • OptionalfileName: string

      Defines the name of the file to load

    Returns Promise<ISceneLoaderAsyncResult>

    The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)

  • Load into a scene.

    Parameters

    • scene: Scene

      The scene to load into

    • data: unknown

      The data to import

    • rootUrl: string

      The root url for scene and resources

    • OptionalonProgress: (event: ISceneLoaderProgressEvent) => void

      The callback when the load progresses

    • OptionalfileName: string

      Defines the name of the file to load

    Returns Promise<void>

    Nothing

  • The callback called when loading from a url.

    Parameters

    • scene: Scene

      scene loading this url

    • fileOrUrl: string | ArrayBufferView<ArrayBufferLike> | File

      file or url to load

    • rootUrl: string

      root url to use to load assets

    • onSuccess: (data: unknown, responseURL?: string) => void

      callback called when the file successfully loads

    • OptionalonProgress: (ev: ISceneLoaderProgressEvent) => void

      callback called while file is loading (if the server supports this mode)

    • OptionaluseArrayBuffer: boolean

      defines a boolean indicating that date must be returned as ArrayBuffer

    • OptionalonError: (request?: WebRequest, exception?: LoadFileError) => void

      callback called when the file fails to load

    • Optionalname: string

      defines the name of the file when loading a binary file

    Returns Nullable<IFileRequest>

    a file request object