API

Interface ISceneLoaderPlugin

Interface used to define a SceneLoader plugin

interface ISceneLoaderPlugin {
    extensions: string | ISceneLoaderPluginExtensions;
    name: string;
    canDirectLoad?(data: string): boolean;
    directLoad?(scene: Scene, data: string): unknown;
    importMesh(
        meshesNames: string | readonly string[] | null | undefined,
        scene: Scene,
        data: unknown,
        rootUrl: string,
        meshes: AbstractMesh[],
        particleSystems: IParticleSystem[],
        skeletons: Skeleton[],
        onError?: (message: string, exception?: any) => void,
    ): boolean;
    load(
        scene: Scene,
        data: unknown,
        rootUrl: string,
        onError?: (message: string, exception?: any) => void,
    ): boolean;
    loadAssetContainer(
        scene: Scene,
        data: unknown,
        rootUrl: string,
        onError?: (message: string, exception?: any) => void,
    ): AssetContainer;
    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

    • meshes: AbstractMesh[]

      The meshes array to import into

    • particleSystems: IParticleSystem[]

      The particle systems array to import into

    • skeletons: Skeleton[]

      The skeletons array to import into

    • OptionalonError: (message: string, exception?: any) => void

      The callback when import fails

    Returns boolean

    True if successful or false otherwise

  • 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

    • OptionalonError: (message: string, exception?: any) => void

      The callback when import fails

    Returns boolean

    True if successful or false otherwise

  • Load into an asset container.

    Parameters

    • scene: Scene

      The scene to load into

    • data: unknown

      The data to import

    • rootUrl: string

      The root url for scene and resources

    • OptionalonError: (message: string, exception?: any) => void

      The callback when import fails

    Returns AssetContainer

    The loaded asset container

  • 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