|
@@ -5,6 +5,11 @@ import { getConfigurationType } from './types';
|
|
import * as deepmerge from '../../assets/deepmerge.min.js';
|
|
import * as deepmerge from '../../assets/deepmerge.min.js';
|
|
import { Tools, IFileRequest } from 'babylonjs';
|
|
import { Tools, IFileRequest } from 'babylonjs';
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * The configuration loader will load the configuration object from any source and will use the defined mapper to
|
|
|
|
+ * parse the object and return a conform ViewerConfiguration.
|
|
|
|
+ * It is a private member of the scene.
|
|
|
|
+ */
|
|
export class ConfigurationLoader {
|
|
export class ConfigurationLoader {
|
|
|
|
|
|
private _configurationCache: { [url: string]: any };
|
|
private _configurationCache: { [url: string]: any };
|
|
@@ -16,6 +21,14 @@ export class ConfigurationLoader {
|
|
this._loadRequests = [];
|
|
this._loadRequests = [];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * load a configuration object that is defined in the initial configuration provided.
|
|
|
|
+ * The viewer configuration can extend different types of configuration objects and have an extra configuration defined.
|
|
|
|
+ *
|
|
|
|
+ * @param initConfig the initial configuration that has the definitions of further configuration to load.
|
|
|
|
+ * @param callback an optional callback that will be called sync, if noconfiguration needs to be loaded or configuration is payload-only
|
|
|
|
+ * @returns A promise that delivers the extended viewer configuration, when done.
|
|
|
|
+ */
|
|
public loadConfiguration(initConfig: ViewerConfiguration = {}, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration> {
|
|
public loadConfiguration(initConfig: ViewerConfiguration = {}, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration> {
|
|
|
|
|
|
let loadedConfig: ViewerConfiguration = deepmerge({}, initConfig);
|
|
let loadedConfig: ViewerConfiguration = deepmerge({}, initConfig);
|
|
@@ -69,6 +82,9 @@ export class ConfigurationLoader {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Dispose the configuration loader. This will cancel file requests, if active.
|
|
|
|
+ */
|
|
public dispose() {
|
|
public dispose() {
|
|
this._loadRequests.forEach(request => {
|
|
this._loadRequests.forEach(request => {
|
|
request.abort();
|
|
request.abort();
|