API

Class SceneLoader

Class used to load scene from various file formats using registered plugins

The module level functions are more efficient for bundler tree shaking and allow plugin options to be passed through. Future improvements to scene loading will primarily be in the module level functions. The SceneLoader class will remain available, but it will be beneficial to prefer the module level functions.

Index
DETAILED_LOGGING: 3 = Constants.SCENELOADER_DETAILED_LOGGING

Detailed logging while loading

MINIMAL_LOGGING: 1 = Constants.SCENELOADER_MINIMAL_LOGGING

Minimal logging while loading

NO_LOGGING: 0 = Constants.SCENELOADER_NO_LOGGING

No logging while loading

OnPluginActivatedObservable: Observable<
    ISceneLoaderPlugin
    | ISceneLoaderPluginAsync,
> = onPluginActivatedObservable

Event raised when a plugin is used to load a scene

SUMMARY_LOGGING: 2 = Constants.SCENELOADER_SUMMARY_LOGGING

Summary logging while loading

  • Append a scene

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      is the instance of BABYLON.Scene to append to

    • OptionalonSuccess: Nullable<(scene: Scene) => void>

      a callback with the scene when import succeeds

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalonError: Nullable<(scene: Scene, message: string, exception?: any) => void>

      a callback with the scene, a message, and possibly an exception when import fails

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the name of the file, if the data is binary

    Returns void

    Please use the module level AppendSceneAsync instead

  • Append a scene

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      is the instance of BABYLON.Scene to append to

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the name of the file, if the data is binary

    Returns Promise<Scene>

    The given scene

    Please use the module level AppendSceneAsync instead

  • Import animations from a file into a scene

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      is the instance of BABYLON.Scene to append to (default: last created scene)

    • OptionaloverwriteAnimations: boolean

      when true, animations are cleaned before importing new ones. Animations are appended otherwise

    • OptionalanimationGroupLoadingMode: SceneLoaderAnimationGroupLoadingMode

      defines how to handle old animations groups before importing new ones

    • OptionaltargetConverter: Nullable<(target: any) => any>

      defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)

    • OptionalonSuccess: Nullable<(scene: Scene) => void>

      a callback with the scene when import succeeds

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalonError: Nullable<(scene: Scene, message: string, exception?: any) => void>

      a callback with the scene, a message, and possibly an exception when import fails

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the filename, if the data is binary

    Returns void

    Please use the module level ImportAnimationsAsync instead

  • Import animations from a file into a scene

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      is the instance of BABYLON.Scene to append to (default: last created scene)

    • OptionaloverwriteAnimations: boolean

      when true, animations are cleaned before importing new ones. Animations are appended otherwise

    • OptionalanimationGroupLoadingMode: SceneLoaderAnimationGroupLoadingMode

      defines how to handle old animations groups before importing new ones

    • OptionaltargetConverter: Nullable<(target: any) => any>

      defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)

    • OptionalonSuccess: Nullable<(scene: Scene) => void>

      a callback with the scene when import succeeds

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalonError: Nullable<(scene: Scene, message: string, exception?: any) => void>

      a callback with the scene, a message, and possibly an exception when import fails

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the filename, if the data is binary

    Returns Promise<Scene>

    the updated scene with imported animations

    Please use the module level ImportAnimationsAsync instead

  • Import meshes into a scene

    Parameters

    • meshNames: 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

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      the instance of BABYLON.Scene to append to

    • OptionalonSuccess: Nullable<SceneLoaderSuccessCallback>

      a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalonError: Nullable<(scene: Scene, message: string, exception?: any) => void>

      a callback with the scene, a message, and possibly an exception when import fails

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the name of the file, if the data is binary

    • OptionalpluginOptions: { [key: string]: { enabled?: boolean; [key: string]: unknown } | undefined }

      defines the options to use with the plugin

    Returns void

    Please use the module level ImportMeshAsync instead

  • Import meshes into a scene

    Parameters

    • meshNames: 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

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      the instance of BABYLON.Scene to append to

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the name of the file

    Returns Promise<ISceneLoaderAsyncResult>

    The loaded list of imported meshes, particle systems, skeletons, and animation groups

    Please use the module level ImportMeshAsync instead

  • Gets a boolean indicating that the given extension can be loaded

    Parameters

    • extension: string

      defines the extension to load

    Returns boolean

    true if the extension is supported

  • Load a scene

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalengine: Nullable<AbstractEngine>

      is the instance of BABYLON.Engine to use to create the scene

    • OptionalonSuccess: Nullable<(scene: Scene) => void>

      a callback with the scene when import succeeds

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalonError: Nullable<(scene: Scene, message: string, exception?: any) => void>

      a callback with the scene, a message, and possibly an exception when import fails

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the filename, if the data is binary

    Returns void

    Please use the module level LoadSceneAsync instead

  • Load a scene into an asset container

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalscene: Nullable<Scene>

      is the instance of BABYLON.Scene to append to (default: last created scene)

    • OptionalonSuccess: Nullable<(assets: AssetContainer) => void>

      a callback with the scene when import succeeds

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalonError: Nullable<(scene: Scene, message: string, exception?: any) => void>

      a callback with the scene, a message, and possibly an exception when import fails

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the filename, if the data is binary

    Returns void

    Please use the module level LoadAssetContainerAsync instead

  • Load a scene into an asset container

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)

    • Optionalscene: Nullable<Scene>

      is the instance of Scene to append to

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the filename, if the data is binary

    Returns Promise<AssetContainer>

    The loaded asset container

    Please use the module level LoadAssetContainerAsync instead

  • Load a scene

    Parameters

    • rootUrl: string

      a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)

    • OptionalsceneFilename: SceneSource

      a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)

    • Optionalengine: Nullable<AbstractEngine>

      is the instance of BABYLON.Engine to use to create the scene

    • OptionalonProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>

      a callback with a progress event for each file being loaded

    • OptionalpluginExtension: Nullable<string>

      the extension used to determine the plugin

    • Optionalname: string

      defines the filename, if the data is binary

    Returns Promise<Scene>

    The loaded scene

    Please use the module level LoadSceneAsync instead