|
@@ -138,7 +138,7 @@
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private static _loadData(rootUrl: string, sceneFilename: string, scene: Scene, onSuccess: (plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync, data: any) => void, onProgress: (event: ProgressEvent) => void, onError: (message: Nullable<string>, exception?: any) => void, pluginExtension?: string): void {
|
|
|
+ private static _loadData(rootUrl: string, sceneFilename: string, scene: Scene, onSuccess: (plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync, data: any) => void, onProgress: (event: ProgressEvent) => void, onError: (message: Nullable<string>, exception?: any) => void, pluginExtension?: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync {
|
|
|
var directLoad = SceneLoader._getDirectLoad(sceneFilename);
|
|
|
var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(sceneFilename) : SceneLoader._getPluginForFilename(sceneFilename));
|
|
|
var plugin = registeredPlugin.plugin;
|
|
@@ -173,7 +173,7 @@
|
|
|
|
|
|
if (directLoad) {
|
|
|
dataCallback(directLoad);
|
|
|
- return;
|
|
|
+ return registeredPlugin.plugin;
|
|
|
}
|
|
|
|
|
|
if (rootUrl.indexOf("file:") === -1) {
|
|
@@ -195,9 +195,9 @@
|
|
|
Tools.ReadFile(FilesInput.FilesToLoad[sceneFilename], dataCallback, onProgress, useArrayBuffer);
|
|
|
} else {
|
|
|
onError("Unable to find file named " + sceneFilename);
|
|
|
- return;
|
|
|
}
|
|
|
}
|
|
|
+ return registeredPlugin.plugin;
|
|
|
}
|
|
|
|
|
|
// Public functions
|
|
@@ -234,10 +234,10 @@
|
|
|
* @param onProgress a callback with a progress event for each file being loaded
|
|
|
* @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
*/
|
|
|
- public static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void> = null, onProgress: Nullable<(event: ProgressEvent) => void> = null, onError: Nullable<(scene: Scene, message: string, exception?: any) => void> = null, pluginExtension?: string): void {
|
|
|
+ public static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void> = null, onProgress: Nullable<(event: ProgressEvent) => void> = null, onError: Nullable<(scene: Scene, message: string, exception?: any) => void> = null, pluginExtension?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync> {
|
|
|
if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
Tools.Error("Wrong sceneFilename parameter");
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
var loadingToken = {};
|
|
@@ -260,7 +260,7 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- SceneLoader._loadData(rootUrl, sceneFilename, scene, (plugin, data) => {
|
|
|
+ return SceneLoader._loadData(rootUrl, sceneFilename, scene, (plugin, data) => {
|
|
|
if ((<any>plugin).importMesh) {
|
|
|
var syncedPlugin = <ISceneLoaderPlugin>plugin;
|
|
|
var meshes = new Array<AbstractMesh>();
|
|
@@ -309,8 +309,8 @@
|
|
|
* @param onProgress a callback with a progress event for each file being loaded
|
|
|
* @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
*/
|
|
|
- public static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void, pluginExtension?: string): void {
|
|
|
- SceneLoader.Append(rootUrl, sceneFilename, new Scene(engine), onSuccess, onProgress, onError, pluginExtension);
|
|
|
+ public static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void, pluginExtension?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync> {
|
|
|
+ return SceneLoader.Append(rootUrl, sceneFilename, new Scene(engine), onSuccess, onProgress, onError, pluginExtension);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -322,10 +322,10 @@
|
|
|
* @param onProgress a callback with a progress event for each file being loaded
|
|
|
* @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
*/
|
|
|
- public static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void, pluginExtension?: string): void {
|
|
|
+ public static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void, pluginExtension?: string): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync> {
|
|
|
if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
Tools.Error("Wrong sceneFilename parameter");
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
if (SceneLoader.ShowLoadingScreen) {
|
|
@@ -353,7 +353,7 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- SceneLoader._loadData(rootUrl, sceneFilename, scene, (plugin, data) => {
|
|
|
+ return SceneLoader._loadData(rootUrl, sceneFilename, scene, (plugin, data) => {
|
|
|
if ((<any>plugin).load) {
|
|
|
var syncedPlugin = <ISceneLoaderPlugin>plugin;
|
|
|
if (!syncedPlugin.load(scene, data, rootUrl, errorHandler)) {
|