Class SceneLoader
Constructors
constructor
-
Returns SceneLoader
Properties
Static ReadonlyDETAILED_ LOGGING
Detailed logging while loading
Static ReadonlyMINIMAL_ LOGGING
Minimal logging while loading
Static ReadonlyNO_ LOGGING
No logging while loading
Static ReadonlyOn Plugin Activated Observable
ISceneLoaderPlugin
| ISceneLoaderPluginAsync,
> = onPluginActivatedObservable
Event raised when a plugin is used to load a scene
Static ReadonlySUMMARY_ LOGGING
Summary logging while loading
Accessors
StaticClean Bone Matrix Weights
-
get CleanBoneMatrixWeights(): boolean
Gets or set a boolean indicating if matrix weights must be cleaned upon loading
Returns boolean
-
set CleanBoneMatrixWeights(value: boolean): void
Parameters
- value: boolean
Returns void
StaticForce Full Scene Loading For Incremental
-
get ForceFullSceneLoadingForIncremental(): boolean
Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
Returns boolean
-
set ForceFullSceneLoadingForIncremental(value: boolean): void
Parameters
- value: boolean
Returns void
Staticlogging Level
-
get loggingLevel(): number
IgnorenamingDefines the current logging level (while loading the scene)
Returns number
-
set loggingLevel(value: number): void
Parameters
- value: number
Returns void
StaticShow Loading Screen
-
get ShowLoadingScreen(): boolean
Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
Returns boolean
-
set ShowLoadingScreen(value: boolean): void
Parameters
- value: boolean
Returns void
Methods
StaticAppend
-
Append(
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
onSuccess?: Nullable<(scene: Scene) => void>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
onError?: Nullable<
(scene: Scene, message: string, exception?: any) => void,
>,
pluginExtension?: Nullable<string>,
name?: string,
): voidAppend 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: SceneSourcea 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: stringdefines the name of the file, if the data is binary
Returns void
Deprecated
Please use the module level AppendSceneAsync instead
- rootUrl: string
StaticAppend Async
-
AppendAsync(
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
pluginExtension?: Nullable<string>,
name?: string,
): Promise<Scene>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: SceneSourcea 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: stringdefines the name of the file, if the data is binary
Returns Promise<Scene>
The given scene
Deprecated
Please use the module level AppendSceneAsync instead
- rootUrl: string
StaticGet Default Plugin
-
Gets the default plugin (used to load Babylon files)
Returns IRegisteredPlugin | undefined
the .babylon plugin
StaticGet Plugin For Extension
-
GetPluginForExtension(
extension: string,
):
| ISceneLoaderPlugin
| ISceneLoaderPluginAsync
| ISceneLoaderPluginFactory
| undefinedGets a plugin that can load the given extension
Parameters
- extension: string
defines the extension to load
Returns
| ISceneLoaderPlugin
| ISceneLoaderPluginAsync
| ISceneLoaderPluginFactory
| undefineda plugin or null if none works
- extension: string
StaticImport Animations
-
ImportAnimations(
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
overwriteAnimations?: boolean,
animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode,
targetConverter?: Nullable<(target: any) => any>,
onSuccess?: Nullable<(scene: Scene) => void>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
onError?: Nullable<
(scene: Scene, message: string, exception?: any) => void,
>,
pluginExtension?: Nullable<string>,
name?: string,
): voidImport 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: SceneSourcea 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: booleanwhen true, animations are cleaned before importing new ones. Animations are appended otherwise
OptionalanimationGroupLoadingMode: SceneLoaderAnimationGroupLoadingModedefines 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: stringdefines the filename, if the data is binary
Returns void
Deprecated
Please use the module level ImportAnimationsAsync instead
- rootUrl: string
StaticImport Animations Async
-
ImportAnimationsAsync(
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
overwriteAnimations?: boolean,
animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode,
targetConverter?: Nullable<(target: any) => any>,
onSuccess?: Nullable<(scene: Scene) => void>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
onError?: Nullable<
(scene: Scene, message: string, exception?: any) => void,
>,
pluginExtension?: Nullable<string>,
name?: string,
): Promise<Scene>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: SceneSourcea 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: booleanwhen true, animations are cleaned before importing new ones. Animations are appended otherwise
OptionalanimationGroupLoadingMode: SceneLoaderAnimationGroupLoadingModedefines 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: stringdefines the filename, if the data is binary
Returns Promise<Scene>
the updated scene with imported animations
Deprecated
Please use the module level ImportAnimationsAsync instead
- rootUrl: string
StaticImport Mesh
-
ImportMesh(
meshNames: string | readonly string[] | null | undefined,
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
onSuccess?: Nullable<SceneLoaderSuccessCallback>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
onError?: Nullable<
(scene: Scene, message: string, exception?: any) => void,
>,
pluginExtension?: Nullable<string>,
name?: string,
pluginOptions?: {
[key: string]:
| { enabled?: boolean; [key: string]: unknown }
| undefined;
},
): voidImport 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: SceneSourcea 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: stringdefines 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
Deprecated
Please use the module level ImportMeshAsync instead
- meshNames: string | readonly string[] | null | undefined
StaticImport Mesh Async
-
ImportMeshAsync(
meshNames: string | readonly string[] | null | undefined,
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
pluginExtension?: Nullable<string>,
name?: string,
): Promise<ISceneLoaderAsyncResult>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: SceneSourcea 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: stringdefines the name of the file
Returns Promise<ISceneLoaderAsyncResult>
The loaded list of imported meshes, particle systems, skeletons, and animation groups
Deprecated
Please use the module level ImportMeshAsync instead
- meshNames: string | readonly string[] | null | undefined
StaticIs Plugin For Extension Available
-
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
- extension: string
StaticLoad
-
Load(
rootUrl: string,
sceneFilename?: SceneSource,
engine?: Nullable<AbstractEngine>,
onSuccess?: Nullable<(scene: Scene) => void>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
onError?: Nullable<
(scene: Scene, message: string, exception?: any) => void,
>,
pluginExtension?: Nullable<string>,
name?: string,
): voidLoad 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: SceneSourcea 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: stringdefines the filename, if the data is binary
Returns void
Deprecated
Please use the module level LoadSceneAsync instead
- rootUrl: string
StaticLoad Asset Container
-
LoadAssetContainer(
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
onSuccess?: Nullable<(assets: AssetContainer) => void>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
onError?: Nullable<
(scene: Scene, message: string, exception?: any) => void,
>,
pluginExtension?: Nullable<string>,
name?: string,
): voidLoad 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: SceneSourcea 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: stringdefines the filename, if the data is binary
Returns void
Deprecated
Please use the module level LoadAssetContainerAsync instead
- rootUrl: string
StaticLoad Asset Container Async
-
LoadAssetContainerAsync(
rootUrl: string,
sceneFilename?: SceneSource,
scene?: Nullable<Scene>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
pluginExtension?: Nullable<string>,
name?: string,
): Promise<AssetContainer>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: SceneSourcea 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: stringdefines the filename, if the data is binary
Returns Promise<AssetContainer>
The loaded asset container
Deprecated
Please use the module level LoadAssetContainerAsync instead
- rootUrl: string
StaticLoad Async
-
LoadAsync(
rootUrl: string,
sceneFilename?: SceneSource,
engine?: Nullable<AbstractEngine>,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
pluginExtension?: Nullable<string>,
name?: string,
): Promise<Scene>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: SceneSourcea 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: stringdefines the filename, if the data is binary
Returns Promise<Scene>
The loaded scene
Deprecated
Please use the module level LoadSceneAsync instead
- rootUrl: string
StaticRegister Plugin
-
RegisterPlugin(
plugin:
| ISceneLoaderPlugin
| ISceneLoaderPluginAsync
| ISceneLoaderPluginFactory,
): voidAdds a new plugin to the list of registered plugins
Parameters
- plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory
defines the plugin to add
Returns void
- plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory
Class used to load scene from various file formats using registered plugins
See
Deprecated
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.