@babylonjs/viewer 5.0.0-beta.3 → 5.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configuration/mappers.js +1 -1
- package/configuration/mappers.js.map +1 -1
- package/configuration/renderOnlyLoader.js +1 -1
- package/configuration/renderOnlyLoader.js.map +1 -1
- package/configuration/types/default.js +1 -1
- package/configuration/types/default.js.map +1 -1
- package/configuration/types/index.js +1 -1
- package/configuration/types/index.js.map +1 -1
- package/managers/sceneManager.d.ts +2 -1
- package/managers/sceneManager.js +4 -5
- package/managers/sceneManager.js.map +1 -1
- package/model/viewerModel.js +1 -1
- package/model/viewerModel.js.map +1 -1
- package/package.json +5 -5
- package/templating/plugins/printButton.js +1 -1
- package/templating/plugins/printButton.js.map +1 -1
- package/templating/templateManager.d.ts +1 -1
- package/templating/templateManager.js +1 -2
- package/templating/templateManager.js.map +1 -1
- package/templating/viewerTemplatePlugin.js +1 -1
- package/templating/viewerTemplatePlugin.js.map +1 -1
- package/viewer/defaultViewer.d.ts +2 -1
- package/viewer/defaultViewer.js +2 -2
- package/viewer/defaultViewer.js.map +1 -1
- package/viewer/renderOnlyViewer.d.ts +1 -1
- package/viewer/renderOnlyViewer.js.map +1 -1
- package/viewer/viewer.d.ts +3 -1
- package/viewer/viewer.js +1 -1
- package/viewer/viewer.js.map +1 -1
package/configuration/mappers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tools } from '@babylonjs/core/Misc/tools.js';
|
|
2
|
-
import { kebabToCamel } from '../helper
|
|
2
|
+
import { kebabToCamel } from '../helper/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* This is a simple HTML mapper.
|
|
5
5
|
* This mapper parses a single HTML element and returns the configuration from its attributes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mappers.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/configuration/mappers.ts"],"names":[],"mappings":"AAAA,OA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ACxB,MAAM,EAAE,IAAI,UAAU,EAAE;YACxB,KAAK,EAAE,IAAI,SAAS,EAAE;SACzB,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,iCAAS,GAAhB,UAAiB,IAAY;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACtB,KAAK,CAAC,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,sCAAc,GAArB,UAAsB,IAAY,EAAE,MAAe;QAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,+BAAO,GAAd;QACI,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACvB,CAAC;IAxCD;;OAEG;IACW,2BAAa,GAAG,MAAM,CAAC;IAuCzC,oBAAC;CAAA,AA7CD,IA6CC;SA7CY,aAAa;AA+C1B;;;;GAIG;AACH,MAAM,CAAC,IAAI,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["import { Tools } from '@babylonjs/core/Misc/tools';\r\nimport { ViewerConfiguration } from './configuration';\r\n\r\nimport { kebabToCamel } from '../helper/';\r\n\r\n/**\r\n * This is the mapper's interface. Implement this function to create your own mapper and register it at the mapper manager\r\n */\r\nexport interface IMapper {\r\n map(rawSource: any): ViewerConfiguration;\r\n}\r\n\r\n/**\r\n * This is a simple HTML mapper.\r\n * This mapper parses a single HTML element and returns the configuration from its attributes.\r\n * it parses numbers and boolean values to the corresponding variable types.\r\n * The following HTML element:\r\n * <div test=\"1\" random-flag=\"true\" a.string.object=\"test\"> will result in the following configuration:\r\n *\r\n * {\r\n * test: 1, //a number!\r\n * randomFlag: boolean, //camelCase and boolean\r\n * a: {\r\n * string: {\r\n * object: \"test\" //dot-separated object levels\r\n * }\r\n * }\r\n * }\r\n */\r\nclass HTMLMapper implements IMapper {\r\n\r\n /**\r\n * Map a specific element and get configuration from it\r\n * @param element the HTML element to analyze.\r\n */\r\n map(element: HTMLElement): ViewerConfiguration {\r\n\r\n let config = {};\r\n for (let attrIdx = 0; attrIdx < element.attributes.length; ++attrIdx) {\r\n let attr = element.attributes.item(attrIdx);\r\n if (!attr) {\r\n continue;\r\n }\r\n // map \"object.property\" to the right configuration place.\r\n let split = attr.nodeName.split('.');\r\n split.reduce((currentConfig, key, idx) => {\r\n //convert html-style to json-style\r\n let camelKey = kebabToCamel(key);\r\n if (idx === split.length - 1) {\r\n let val: any = attr!.nodeValue; // firefox warns nodeValue is deprecated, but I found no sign of it anywhere.\r\n if (val === \"true\") {\r\n val = true;\r\n } else if (val === \"false\") {\r\n val = false;\r\n } else if (val === \"undefined\") {\r\n val = undefined;\r\n } else if (val === \"null\") {\r\n val = null;\r\n } else {\r\n var isnum = !isNaN(parseFloat(val)) && isFinite(val); ///^\\d+$/.test(val);\r\n if (isnum) {\r\n let number = parseFloat(val);\r\n if (!isNaN(number)) {\r\n val = number;\r\n }\r\n }\r\n }\r\n currentConfig[camelKey] = val;\r\n } else {\r\n currentConfig[camelKey] = currentConfig[camelKey] || {};\r\n }\r\n return currentConfig[camelKey];\r\n }, config);\r\n }\r\n\r\n return config;\r\n }\r\n}\r\n\r\n/**\r\n * A simple string-to-JSON mapper.\r\n * This is the main mapper, used to analyze downloaded JSON-Configuration or JSON payload\r\n */\r\nclass JSONMapper implements IMapper {\r\n map(rawSource: string) {\r\n return JSON.parse(rawSource);\r\n }\r\n}\r\n\r\n/**\r\n * The DOM Mapper will traverse an entire DOM Tree and will load the configuration from the\r\n * DOM elements and attributes.\r\n */\r\nclass DOMMapper implements IMapper {\r\n\r\n /**\r\n * The mapping function that will convert HTML data to a viewer configuration object\r\n * @param baseElement the baseElement from which to start traversing\r\n * @returns a ViewerCOnfiguration object from the provided HTML Element\r\n */\r\n map(baseElement: HTMLElement): ViewerConfiguration {\r\n let htmlMapper = new HTMLMapper();\r\n let config = htmlMapper.map(baseElement);\r\n\r\n let traverseChildren = function (element: HTMLElement, partConfig) {\r\n let children = element.children;\r\n if (children.length) {\r\n for (let i = 0; i < children.length; ++i) {\r\n let item = <HTMLElement>children.item(i);\r\n // use the HTML Mapper to read configuration from a single element\r\n let configMapped = htmlMapper.map(item);\r\n let key = kebabToCamel(item.nodeName.toLowerCase());\r\n if (item.attributes.getNamedItem('array') && item.attributes.getNamedItem('array')!.nodeValue === 'true') {\r\n partConfig[key] = [];\r\n } else {\r\n if (element.attributes.getNamedItem('array') && element.attributes.getNamedItem('array')!.nodeValue === 'true') {\r\n partConfig.push(configMapped);\r\n } else if (partConfig[key]) {\r\n //exists already! probably an array\r\n element.setAttribute('array', 'true');\r\n let oldItem = partConfig[key];\r\n partConfig = [oldItem, configMapped];\r\n } else {\r\n partConfig[key] = configMapped;\r\n }\r\n }\r\n traverseChildren(item, partConfig[key] || configMapped);\r\n }\r\n }\r\n return partConfig;\r\n };\r\n\r\n traverseChildren(baseElement, config);\r\n\r\n return config;\r\n }\r\n\r\n}\r\n\r\n/**\r\n * The MapperManager manages the different implemented mappers.\r\n * It allows the user to register new mappers as well and use them to parse their own configuration data\r\n */\r\nexport class MapperManager {\r\n\r\n private _mappers: { [key: string]: IMapper };\r\n /**\r\n * The default mapper is the JSON mapper.\r\n */\r\n public static DefaultMapper = 'json';\r\n\r\n constructor() {\r\n this._mappers = {\r\n \"html\": new HTMLMapper(),\r\n \"json\": new JSONMapper(),\r\n \"dom\": new DOMMapper()\r\n };\r\n }\r\n\r\n /**\r\n * Get a specific configuration mapper.\r\n *\r\n * @param type the name of the mapper to load\r\n */\r\n public getMapper(type: string) {\r\n if (!this._mappers[type]) {\r\n Tools.Error(\"No mapper defined for \" + type);\r\n }\r\n return this._mappers[type];\r\n }\r\n\r\n /**\r\n * Use this functio to register your own configuration mapper.\r\n * After a mapper is registered, it can be used to parse the specific type fo configuration to the standard ViewerConfiguration.\r\n * @param type the name of the mapper. This will be used to define the configuration type and/or to get the mapper\r\n * @param mapper The implemented mapper\r\n */\r\n public registerMapper(type: string, mapper: IMapper) {\r\n this._mappers[type] = mapper;\r\n }\r\n\r\n /**\r\n * Dispose the mapper manager and all of its mappers.\r\n */\r\n public dispose() {\r\n this._mappers = {};\r\n }\r\n\r\n}\r\n\r\n/**\r\n * mapperManager is a singleton of the type MapperManager.\r\n * The mapperManager can be disposed directly with calling mapperManager.dispose()\r\n * or indirectly with using BabylonViewer.disposeAll()\r\n */\r\nexport let mapperManager = new MapperManager();"]}
|
|
1
|
+
{"version":3,"file":"mappers.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/configuration/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS/C;;;;;;;;;;;;;;;;GAgBG;AACH;IAAA;IAgDA,CAAC;IA9CG;;;OAGG;IACH,wBAAG,GAAH,UAAI,OAAoB;QAEpB,IAAI,MAAM,GAAG,EAAE,CAAC;gCACP,OAAO;YACZ,IAAI,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,CAAC,IAAI,EAAE;;aAEV;YACD,0DAA0D;YAC1D,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrC,KAAK,CAAC,MAAM,CAAC,UAAC,aAAa,EAAE,GAAG,EAAE,GAAG;gBACjC,kCAAkC;gBAClC,IAAI,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;gBACjC,IAAI,GAAG,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC1B,IAAI,GAAG,GAAQ,IAAK,CAAC,SAAS,CAAC,CAAC,6EAA6E;oBAC7G,IAAI,GAAG,KAAK,MAAM,EAAE;wBAChB,GAAG,GA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ViewerConfiguration } from './configuration';\r\n\r\nimport { kebabToCamel } from '../helper/index';\r\n\r\n/**\r\n * This is the mapper's interface. Implement this function to create your own mapper and register it at the mapper manager\r\n */\r\nexport interface IMapper {\r\n map(rawSource: any): ViewerConfiguration;\r\n}\r\n\r\n/**\r\n * This is a simple HTML mapper.\r\n * This mapper parses a single HTML element and returns the configuration from its attributes.\r\n * it parses numbers and boolean values to the corresponding variable types.\r\n * The following HTML element:\r\n * <div test=\"1\" random-flag=\"true\" a.string.object=\"test\"> will result in the following configuration:\r\n *\r\n * {\r\n * test: 1, //a number!\r\n * randomFlag: boolean, //camelCase and boolean\r\n * a: {\r\n * string: {\r\n * object: \"test\" //dot-separated object levels\r\n * }\r\n * }\r\n * }\r\n */\r\nclass HTMLMapper implements IMapper {\r\n\r\n /**\r\n * Map a specific element and get configuration from it\r\n * @param element the HTML element to analyze.\r\n */\r\n map(element: HTMLElement): ViewerConfiguration {\r\n\r\n let config = {};\r\n for (let attrIdx = 0; attrIdx < element.attributes.length; ++attrIdx) {\r\n let attr = element.attributes.item(attrIdx);\r\n if (!attr) {\r\n continue;\r\n }\r\n // map \"object.property\" to the right configuration place.\r\n let split = attr.nodeName.split('.');\r\n split.reduce((currentConfig, key, idx) => {\r\n //convert html-style to json-style\r\n let camelKey = kebabToCamel(key);\r\n if (idx === split.length - 1) {\r\n let val: any = attr!.nodeValue; // firefox warns nodeValue is deprecated, but I found no sign of it anywhere.\r\n if (val === \"true\") {\r\n val = true;\r\n } else if (val === \"false\") {\r\n val = false;\r\n } else if (val === \"undefined\") {\r\n val = undefined;\r\n } else if (val === \"null\") {\r\n val = null;\r\n } else {\r\n var isnum = !isNaN(parseFloat(val)) && isFinite(val); ///^\\d+$/.test(val);\r\n if (isnum) {\r\n let number = parseFloat(val);\r\n if (!isNaN(number)) {\r\n val = number;\r\n }\r\n }\r\n }\r\n currentConfig[camelKey] = val;\r\n } else {\r\n currentConfig[camelKey] = currentConfig[camelKey] || {};\r\n }\r\n return currentConfig[camelKey];\r\n }, config);\r\n }\r\n\r\n return config;\r\n }\r\n}\r\n\r\n/**\r\n * A simple string-to-JSON mapper.\r\n * This is the main mapper, used to analyze downloaded JSON-Configuration or JSON payload\r\n */\r\nclass JSONMapper implements IMapper {\r\n map(rawSource: string) {\r\n return JSON.parse(rawSource);\r\n }\r\n}\r\n\r\n/**\r\n * The DOM Mapper will traverse an entire DOM Tree and will load the configuration from the\r\n * DOM elements and attributes.\r\n */\r\nclass DOMMapper implements IMapper {\r\n\r\n /**\r\n * The mapping function that will convert HTML data to a viewer configuration object\r\n * @param baseElement the baseElement from which to start traversing\r\n * @returns a ViewerCOnfiguration object from the provided HTML Element\r\n */\r\n map(baseElement: HTMLElement): ViewerConfiguration {\r\n let htmlMapper = new HTMLMapper();\r\n let config = htmlMapper.map(baseElement);\r\n\r\n let traverseChildren = function (element: HTMLElement, partConfig) {\r\n let children = element.children;\r\n if (children.length) {\r\n for (let i = 0; i < children.length; ++i) {\r\n let item = <HTMLElement>children.item(i);\r\n // use the HTML Mapper to read configuration from a single element\r\n let configMapped = htmlMapper.map(item);\r\n let key = kebabToCamel(item.nodeName.toLowerCase());\r\n if (item.attributes.getNamedItem('array') && item.attributes.getNamedItem('array')!.nodeValue === 'true') {\r\n partConfig[key] = [];\r\n } else {\r\n if (element.attributes.getNamedItem('array') && element.attributes.getNamedItem('array')!.nodeValue === 'true') {\r\n partConfig.push(configMapped);\r\n } else if (partConfig[key]) {\r\n //exists already! probably an array\r\n element.setAttribute('array', 'true');\r\n let oldItem = partConfig[key];\r\n partConfig = [oldItem, configMapped];\r\n } else {\r\n partConfig[key] = configMapped;\r\n }\r\n }\r\n traverseChildren(item, partConfig[key] || configMapped);\r\n }\r\n }\r\n return partConfig;\r\n };\r\n\r\n traverseChildren(baseElement, config);\r\n\r\n return config;\r\n }\r\n\r\n}\r\n\r\n/**\r\n * The MapperManager manages the different implemented mappers.\r\n * It allows the user to register new mappers as well and use them to parse their own configuration data\r\n */\r\nexport class MapperManager {\r\n\r\n private _mappers: { [key: string]: IMapper };\r\n /**\r\n * The default mapper is the JSON mapper.\r\n */\r\n public static DefaultMapper = 'json';\r\n\r\n constructor() {\r\n this._mappers = {\r\n \"html\": new HTMLMapper(),\r\n \"json\": new JSONMapper(),\r\n \"dom\": new DOMMapper()\r\n };\r\n }\r\n\r\n /**\r\n * Get a specific configuration mapper.\r\n *\r\n * @param type the name of the mapper to load\r\n */\r\n public getMapper(type: string) {\r\n if (!this._mappers[type]) {\r\n Tools.Error(\"No mapper defined for \" + type);\r\n }\r\n return this._mappers[type];\r\n }\r\n\r\n /**\r\n * Use this functio to register your own configuration mapper.\r\n * After a mapper is registered, it can be used to parse the specific type fo configuration to the standard ViewerConfiguration.\r\n * @param type the name of the mapper. This will be used to define the configuration type and/or to get the mapper\r\n * @param mapper The implemented mapper\r\n */\r\n public registerMapper(type: string, mapper: IMapper) {\r\n this._mappers[type] = mapper;\r\n }\r\n\r\n /**\r\n * Dispose the mapper manager and all of its mappers.\r\n */\r\n public dispose() {\r\n this._mappers = {};\r\n }\r\n\r\n}\r\n\r\n/**\r\n * mapperManager is a singleton of the type MapperManager.\r\n * The mapperManager can be disposed directly with calling mapperManager.dispose()\r\n * or indirectly with using BabylonViewer.disposeAll()\r\n */\r\nexport let mapperManager = new MapperManager();"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mapperManager } from './mappers.js';
|
|
2
2
|
import { processConfigurationCompatibility } from './configurationCompatibility.js';
|
|
3
|
-
import { deepmerge } from '../helper.js';
|
|
3
|
+
import { deepmerge } from '../helper/index.js';
|
|
4
4
|
import { Tools } from '@babylonjs/core/Misc/tools.js';
|
|
5
5
|
import { extendedConfiguration } from './types/extended.js';
|
|
6
6
|
import { renderOnlyDefaultConfiguration } from './types/renderOnlyDefault.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderOnlyLoader.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/configuration/renderOnlyLoader.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AAE,CAAC,CAAC,CAAC;iBACrC;gBACD,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;YACH,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,oCAAC;AAAD,CAAC,AArJD,IAqJC","sourcesContent":["import { mapperManager } from './mappers';\r\nimport { ViewerConfiguration } from './configuration';\r\nimport { processConfigurationCompatibility } from './configurationCompatibility';\r\n\r\nimport { deepmerge } from '../helper';\r\nimport { Tools } from '@babylonjs/core/Misc/tools';\r\nimport { extendedConfiguration } from './types/extended';\r\nimport { renderOnlyDefaultConfiguration } from './types/renderOnlyDefault';\r\nimport { IFileRequest } from '@babylonjs/core/Misc/fileRequest';\r\n\r\n/**\r\n * The configuration loader will load the configuration object from any source and will use the defined mapper to\r\n * parse the object and return a conform ViewerConfiguration.\r\n * It is a private member of the scene.\r\n */\r\nexport class RenderOnlyConfigurationLoader {\r\n\r\n private _configurationCache: { [url: string]: any };\r\n\r\n private _loadRequests: Array<IFileRequest>;\r\n\r\n constructor(private _enableCache: boolean = false) {\r\n this._configurationCache = {};\r\n this._loadRequests = [];\r\n }\r\n\r\n private _getConfigurationTypeExcludeTemplate(types: string): ViewerConfiguration {\r\n let config: ViewerConfiguration = {};\r\n let typesSeparated = types.split(\",\");\r\n typesSeparated.forEach((type) => {\r\n switch (type.trim()) {\r\n case 'default':\r\n config = deepmerge(config, renderOnlyDefaultConfiguration);\r\n break;\r\n case 'none':\r\n break;\r\n case 'extended':\r\n default:\r\n config = deepmerge(config, extendedConfiguration);\r\n break;\r\n }\r\n if (config.extends) {\r\n config = deepmerge(config, this._getConfigurationTypeExcludeTemplate(config.extends));\r\n }\r\n });\r\n return config;\r\n };\r\n\r\n protected getExtendedConfig(type: string | undefined) {\r\n return this._getConfigurationTypeExcludeTemplate(type || \"extended\");\r\n }\r\n\r\n /**\r\n * load a configuration object that is defined in the initial configuration provided.\r\n * The viewer configuration can extend different types of configuration objects and have an extra configuration defined.\r\n *\r\n * @param initConfig the initial configuration that has the definitions of further configuration to load.\r\n * @param callback an optional callback that will be called sync, if noconfiguration needs to be loaded or configuration is payload-only\r\n * @returns A promise that delivers the extended viewer configuration, when done.\r\n */\r\n public loadConfiguration(initConfig: ViewerConfiguration = {}, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration> {\r\n\r\n let loadedConfig: ViewerConfiguration = deepmerge({}, initConfig);\r\n this._processInitialConfiguration(loadedConfig);\r\n\r\n let extendedConfiguration = this.getExtendedConfig(loadedConfig.extends);\r\n\r\n if (loadedConfig.configuration) {\r\n\r\n let mapperType = \"json\";\r\n return Promise.resolve().then(() => {\r\n if (typeof loadedConfig.configuration === \"string\" || (loadedConfig.configuration && loadedConfig.configuration.url)) {\r\n // a file to load\r\n\r\n let url: string = '';\r\n if (typeof loadedConfig.configuration === \"string\") {\r\n url = loadedConfig.configuration;\r\n }\r\n\r\n // if configuration is an object\r\n if (typeof loadedConfig.configuration === \"object\" && loadedConfig.configuration.url) {\r\n url = loadedConfig.configuration.url;\r\n let type = loadedConfig.configuration.mapper;\r\n // empty string?\r\n if (!type) {\r\n // load mapper type from filename / url\r\n type = loadedConfig.configuration.url.split('.').pop();\r\n }\r\n mapperType = type || mapperType;\r\n }\r\n return this._loadFile(url);\r\n } else {\r\n if (typeof loadedConfig.configuration === \"object\") {\r\n mapperType = loadedConfig.configuration.mapper || mapperType;\r\n return loadedConfig.configuration.payload || {};\r\n }\r\n return {};\r\n\r\n }\r\n }).then((data: any) => {\r\n let mapper = mapperManager.getMapper(mapperType);\r\n let parsed = deepmerge(mapper.map(data), loadedConfig);\r\n let merged = deepmerge(extendedConfiguration, parsed);\r\n processConfigurationCompatibility(merged);\r\n if (callback) { callback(merged); }\r\n return merged;\r\n });\r\n } else {\r\n loadedConfig = deepmerge(extendedConfiguration, loadedConfig);\r\n processConfigurationCompatibility(loadedConfig);\r\n if (callback) { callback(loadedConfig); }\r\n return Promise.resolve(loadedConfig);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the configuration loader. This will cancel file requests, if active.\r\n */\r\n public dispose() {\r\n this._loadRequests.forEach((request) => {\r\n request.abort();\r\n });\r\n this._loadRequests.length = 0;\r\n }\r\n\r\n /**\r\n * This function will process the initial configuration and make needed changes for the viewer to work.\r\n * @param config the mutable(!) initial configuration to process\r\n */\r\n private _processInitialConfiguration(config: ViewerConfiguration) {\r\n if (config.model) {\r\n if (typeof config.model === \"string\") {\r\n config.model = {\r\n url: config.model\r\n };\r\n }\r\n }\r\n }\r\n\r\n private _loadFile(url: string): Promise<any> {\r\n let cacheReference = this._configurationCache;\r\n if (this._enableCache && cacheReference[url]) {\r\n return Promise.resolve(cacheReference[url]);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n let fileRequest = Tools.LoadFile(url, (result) => {\r\n let idx = this._loadRequests.indexOf(fileRequest);\r\n if (idx !== -1) {\r\n this._loadRequests.splice(idx, 1);\r\n }\r\n if (this._enableCache) { cacheReference[url] = result; }\r\n resolve(result);\r\n }, undefined, undefined, false, (request, error: any) => {\r\n let idx = this._loadRequests.indexOf(fileRequest);\r\n if (idx !== -1) {\r\n this._loadRequests.splice(idx, 1);\r\n }\r\n reject(error);\r\n });\r\n this._loadRequests.push(fileRequest);\r\n });\r\n }\r\n\r\n}"]}
|
|
1
|
+
{"version":3,"file":"renderOnlyLoader.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/configuration/renderOnlyLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,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,UAAkB,GAAW;QAA7B,iBAuBC;QAtBG,IAAI,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC;QAC9C,IAAI,IAAI,CAAC,YAAY,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE;YAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/C;QAED,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,IAAI,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAC,MAAM;gBACzC,IAAI,GAAG,GAAG,KAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAClD,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE;oBACZ,KAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;iBACrC;gBACD,IAAI,KAAI,CAAC,YAAY,EAAE;oBAAE,cAAc,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;iBAAE;gBACxD,OAAO,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAC,OAAO,EAAE,KAAU;gBAChD,IAAI,GAAG,GAAG,KAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAClD,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE;oBACZ,KAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;iBACrC;gBACD,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;YACH,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,oCAAC;AAAD,CAAC,AArJD,IAqJC","sourcesContent":["import { mapperManager } from './mappers';\r\nimport { ViewerConfiguration } from './configuration';\r\nimport { processConfigurationCompatibility } from './configurationCompatibility';\r\n\r\nimport { deepmerge } from '../helper/index';\r\nimport { Tools } from '@babylonjs/core/Misc/tools';\r\nimport { extendedConfiguration } from './types/extended';\r\nimport { renderOnlyDefaultConfiguration } from './types/renderOnlyDefault';\r\nimport { IFileRequest } from '@babylonjs/core/Misc/fileRequest';\r\n\r\n/**\r\n * The configuration loader will load the configuration object from any source and will use the defined mapper to\r\n * parse the object and return a conform ViewerConfiguration.\r\n * It is a private member of the scene.\r\n */\r\nexport class RenderOnlyConfigurationLoader {\r\n\r\n private _configurationCache: { [url: string]: any };\r\n\r\n private _loadRequests: Array<IFileRequest>;\r\n\r\n constructor(private _enableCache: boolean = false) {\r\n this._configurationCache = {};\r\n this._loadRequests = [];\r\n }\r\n\r\n private _getConfigurationTypeExcludeTemplate(types: string): ViewerConfiguration {\r\n let config: ViewerConfiguration = {};\r\n let typesSeparated = types.split(\",\");\r\n typesSeparated.forEach((type) => {\r\n switch (type.trim()) {\r\n case 'default':\r\n config = deepmerge(config, renderOnlyDefaultConfiguration);\r\n break;\r\n case 'none':\r\n break;\r\n case 'extended':\r\n default:\r\n config = deepmerge(config, extendedConfiguration);\r\n break;\r\n }\r\n if (config.extends) {\r\n config = deepmerge(config, this._getConfigurationTypeExcludeTemplate(config.extends));\r\n }\r\n });\r\n return config;\r\n };\r\n\r\n protected getExtendedConfig(type: string | undefined) {\r\n return this._getConfigurationTypeExcludeTemplate(type || \"extended\");\r\n }\r\n\r\n /**\r\n * load a configuration object that is defined in the initial configuration provided.\r\n * The viewer configuration can extend different types of configuration objects and have an extra configuration defined.\r\n *\r\n * @param initConfig the initial configuration that has the definitions of further configuration to load.\r\n * @param callback an optional callback that will be called sync, if noconfiguration needs to be loaded or configuration is payload-only\r\n * @returns A promise that delivers the extended viewer configuration, when done.\r\n */\r\n public loadConfiguration(initConfig: ViewerConfiguration = {}, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration> {\r\n\r\n let loadedConfig: ViewerConfiguration = deepmerge({}, initConfig);\r\n this._processInitialConfiguration(loadedConfig);\r\n\r\n let extendedConfiguration = this.getExtendedConfig(loadedConfig.extends);\r\n\r\n if (loadedConfig.configuration) {\r\n\r\n let mapperType = \"json\";\r\n return Promise.resolve().then(() => {\r\n if (typeof loadedConfig.configuration === \"string\" || (loadedConfig.configuration && loadedConfig.configuration.url)) {\r\n // a file to load\r\n\r\n let url: string = '';\r\n if (typeof loadedConfig.configuration === \"string\") {\r\n url = loadedConfig.configuration;\r\n }\r\n\r\n // if configuration is an object\r\n if (typeof loadedConfig.configuration === \"object\" && loadedConfig.configuration.url) {\r\n url = loadedConfig.configuration.url;\r\n let type = loadedConfig.configuration.mapper;\r\n // empty string?\r\n if (!type) {\r\n // load mapper type from filename / url\r\n type = loadedConfig.configuration.url.split('.').pop();\r\n }\r\n mapperType = type || mapperType;\r\n }\r\n return this._loadFile(url);\r\n } else {\r\n if (typeof loadedConfig.configuration === \"object\") {\r\n mapperType = loadedConfig.configuration.mapper || mapperType;\r\n return loadedConfig.configuration.payload || {};\r\n }\r\n return {};\r\n\r\n }\r\n }).then((data: any) => {\r\n let mapper = mapperManager.getMapper(mapperType);\r\n let parsed = deepmerge(mapper.map(data), loadedConfig);\r\n let merged = deepmerge(extendedConfiguration, parsed);\r\n processConfigurationCompatibility(merged);\r\n if (callback) { callback(merged); }\r\n return merged;\r\n });\r\n } else {\r\n loadedConfig = deepmerge(extendedConfiguration, loadedConfig);\r\n processConfigurationCompatibility(loadedConfig);\r\n if (callback) { callback(loadedConfig); }\r\n return Promise.resolve(loadedConfig);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the configuration loader. This will cancel file requests, if active.\r\n */\r\n public dispose() {\r\n this._loadRequests.forEach((request) => {\r\n request.abort();\r\n });\r\n this._loadRequests.length = 0;\r\n }\r\n\r\n /**\r\n * This function will process the initial configuration and make needed changes for the viewer to work.\r\n * @param config the mutable(!) initial configuration to process\r\n */\r\n private _processInitialConfiguration(config: ViewerConfiguration) {\r\n if (config.model) {\r\n if (typeof config.model === \"string\") {\r\n config.model = {\r\n url: config.model\r\n };\r\n }\r\n }\r\n }\r\n\r\n private _loadFile(url: string): Promise<any> {\r\n let cacheReference = this._configurationCache;\r\n if (this._enableCache && cacheReference[url]) {\r\n return Promise.resolve(cacheReference[url]);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n let fileRequest = Tools.LoadFile(url, (result) => {\r\n let idx = this._loadRequests.indexOf(fileRequest);\r\n if (idx !== -1) {\r\n this._loadRequests.splice(idx, 1);\r\n }\r\n if (this._enableCache) { cacheReference[url] = result; }\r\n resolve(result);\r\n }, undefined, undefined, false, (request, error: any) => {\r\n let idx = this._loadRequests.indexOf(fileRequest);\r\n if (idx !== -1) {\r\n this._loadRequests.splice(idx, 1);\r\n }\r\n reject(error);\r\n });\r\n this._loadRequests.push(fileRequest);\r\n });\r\n }\r\n\r\n}"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { babylonFont, defaultTemplate, fillContainer, loadingScreen, defaultViewer, navbar, overlay, help, share, error } from 'babylonjs-viewer-assets';
|
|
2
2
|
import * as images from 'babylonjs-viewer-assets';
|
|
3
3
|
import { renderOnlyDefaultConfiguration } from './renderOnlyDefault.js';
|
|
4
|
-
import { deepmerge } from '../../helper.js';
|
|
4
|
+
import { deepmerge } from '../../helper/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* The default configuration of the viewer, including templates (canvas, overly, loading screen)
|
|
7
7
|
* This configuration doesn't hold specific parameters, and only defines objects that are needed for the viewer to fully work correctly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../../../sourceES6/viewer/src/configuration/types/default.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACzJ,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../../../sourceES6/viewer/src/configuration/types/default.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACzJ,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,IAAI,oBAAoB,GAAwB,SAAS,CAAC,8BAA8B,EAAE;IAC7F,OAAO,EAAE,cAAc;IACvB,SAAS,EAAE;QACP,IAAI,EAAE;YACF,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE;gBACJ,WAAW,EAAE,WAAW;gBACxB,QAAQ,EAAE,IAAI;aACjB;SACJ;QACD,aAAa,EAAE;YACX,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE;gBACJ,OAAO,EAAE,KAAK;aACjB;SACJ;QACD,aAAa,EAAE;YACX,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE;gBACJ,eAAe,EAAE,SAAS;gBAC1B,YAAY,EAAE,MAAM,CAAC,OAAO;gBAC5B,kBAAkB,EAAE,MAAM,CAAC,aAAa;aAC3C;SACJ;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE;gBACJ,iBAAiB,EAAE,KAAK;aAC3B;SACJ;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE;gBACJ,SAAS,EAAE;o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ACJ;KACJ;IACD,MAAM,EAAE,EACP;IACD,MAAM,EAAE;QACJ,cAAc,EAAE,IAAI;KACvB;IACD,MAAM,EAAE;QACJ,YAAY,EAAE,IAAI;KACrB;IACD,KAAK,EAAE,EACN;CACJ,CAAC,CAAC","sourcesContent":["import { ViewerConfiguration } from '../configuration';\r\nimport { babylonFont, defaultTemplate, fillContainer, loadingScreen, defaultViewer, navbar, overlay, help, share, error } from 'babylonjs-viewer-assets';\r\nimport * as images from 'babylonjs-viewer-assets';\r\nimport { renderOnlyDefaultConfiguration } from './renderOnlyDefault';\r\nimport { deepmerge } from '../../helper/index';\r\n\r\n/**\r\n * The default configuration of the viewer, including templates (canvas, overly, loading screen)\r\n * This configuration doesn't hold specific parameters, and only defines objects that are needed for the viewer to fully work correctly.\r\n */\r\nexport let defaultConfiguration: ViewerConfiguration = deepmerge(renderOnlyDefaultConfiguration, {\r\n version: \"3.2.0-alpha4\",\r\n templates: {\r\n main: {\r\n html: defaultTemplate,\r\n params: {\r\n babylonFont: babylonFont,\r\n noEscape: true\r\n }\r\n },\r\n fillContainer: {\r\n html: fillContainer,\r\n params: {\r\n disable: false\r\n }\r\n },\r\n loadingScreen: {\r\n html: loadingScreen,\r\n params: {\r\n backgroundColor: \"#000000\",\r\n loadingImage: images.loading,\r\n staticLoadingImage: images.staticLoading\r\n }\r\n },\r\n viewer: {\r\n html: defaultViewer,\r\n params: {\r\n enableDragAndDrop: false\r\n }\r\n },\r\n navBar: {\r\n html: navbar,\r\n params: {\r\n speedList: {\r\n \"0.5x\": \"0.5\",\r\n \"1.0x\": \"1.0\",\r\n \"1.5x\": \"1.5\",\r\n \"2.0x\": \"2.0\",\r\n },\r\n logoImage: images.babylonLogo,\r\n logoText: 'BabylonJS',\r\n logoLink: 'https://babylonjs.com',\r\n hideHelp: true,\r\n hideHd: true,\r\n hideVr: true,\r\n hidePrint: true,\r\n disableOnFullscreen: false,\r\n text: {\r\n hdButton: \"Toggle HD\",\r\n fullscreenButton: \"Toggle Fullscreen\",\r\n helpButton: \"Help\",\r\n vrButton: \"Toggle VR\",\r\n printButton: \"3D Print Object\"\r\n }\r\n },\r\n events: {\r\n click: {\r\n '.navbar-control': true\r\n },\r\n pointerdown: {\r\n '.help-button': true\r\n },\r\n input: {\r\n '.progress-wrapper': true\r\n },\r\n pointerup: {\r\n '.progress-wrapper': true\r\n }\r\n }\r\n },\r\n overlay: {\r\n html: overlay,\r\n params: {\r\n closeImage: images.close,\r\n closeText: 'Close'\r\n }\r\n },\r\n help: {\r\n html: help\r\n },\r\n share: {\r\n html: share\r\n },\r\n error: {\r\n html: error\r\n }\r\n\r\n },\r\n camera: {\r\n behaviors: {\r\n autoRotate: {\r\n type: 0\r\n },\r\n framing: {\r\n type: 2,\r\n zoomOnBoundingInfo: true,\r\n zoomStopsAnimation: false\r\n },\r\n bouncing: {\r\n type: 1\r\n }\r\n }\r\n },\r\n skybox: {\r\n },\r\n ground: {\r\n receiveShadows: true\r\n },\r\n engine: {\r\n antialiasing: true\r\n },\r\n scene: {\r\n }\r\n});\r\n"]}
|
|
@@ -3,7 +3,7 @@ import { defaultConfiguration } from './default.js';
|
|
|
3
3
|
import { extendedConfiguration } from './extended.js';
|
|
4
4
|
import { shadowDirectionalLightConfiguration, shadowSpotlLightConfiguration } from './shadowLight.js';
|
|
5
5
|
import { environmentMapConfiguration } from './environmentMap.js';
|
|
6
|
-
import { deepmerge } from '../../helper
|
|
6
|
+
import { deepmerge } from '../../helper/index.js';
|
|
7
7
|
/**
|
|
8
8
|
* Get the configuration type you need to use as the base for your viewer.
|
|
9
9
|
* The types can either be a single string, or comma separated types that will extend each other. for example:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/viewer/src/configuration/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,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AC;gBACjD,MAAM;YACV,KAAK,SAAS;gBACV,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;gBACjD,MAAM;YACV,KAAK,MAAM;gBACP,MAAM;YACV,KAAK,UAAU,CAAC;YAChB;gBACI,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;gBAClD,MAAM;SACb;QAED,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;SACpE;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAElB,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { minimalConfiguration } from './minimal';\r\nimport { defaultConfiguration } from './default';\r\nimport { extendedConfiguration } from './extended';\r\nimport { ViewerConfiguration } from '../configuration';\r\nimport { shadowDirectionalLightConfiguration, shadowSpotlLightConfiguration } from './shadowLight';\r\nimport { environmentMapConfiguration } from './environmentMap';\r\nimport { deepmerge } from '../../helper/index';\r\n\r\n/**\r\n * Get the configuration type you need to use as the base for your viewer.\r\n * The types can either be a single string, or comma separated types that will extend each other. for example:\r\n *\r\n * \"default, environmentMap\" will first load the default configuration and will extend it using the environmentMap configuration.\r\n *\r\n * @param types a comma-separated string of the type(s) or configuration to load.\r\n */\r\nlet getConfigurationType = function (types: string): ViewerConfiguration {\r\n let config: ViewerConfiguration = {};\r\n let typesSeparated = types.split(\",\");\r\n typesSeparated.forEach((type) => {\r\n switch (type.trim()) {\r\n case 'environmentMap':\r\n config = deepmerge(config, environmentMapConfiguration);\r\n break;\r\n case 'shadowDirectionalLight':\r\n config = deepmerge(config, shadowDirectionalLightConfiguration);\r\n break;\r\n case 'shadowSpotLight':\r\n config = deepmerge(config, shadowSpotlLightConfiguration);\r\n break;\r\n case 'default':\r\n config = deepmerge(config, defaultConfiguration);\r\n break;\r\n case 'minimal':\r\n config = deepmerge(config, minimalConfiguration);\r\n break;\r\n case 'none':\r\n break;\r\n case 'extended':\r\n default:\r\n config = deepmerge(config, extendedConfiguration);\r\n break;\r\n }\r\n\r\n if (config.extends) {\r\n config = deepmerge(config, getConfigurationType(config.extends));\r\n }\r\n });\r\n return config;\r\n\r\n};\r\n\r\nexport { getConfigurationType, defaultConfiguration, minimalConfiguration };"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ILightConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, ICameraConfiguration, ISkyboxConfiguration,
|
|
1
|
+
import { ILightConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, ICameraConfiguration, ISkyboxConfiguration, IGroundConfiguration, IModelConfiguration, IVRConfiguration } from '../configuration/interfaces/index';
|
|
2
|
+
import { ViewerConfiguration } from '../configuration/configuration';
|
|
2
3
|
import { ViewerModel } from '../model/viewerModel';
|
|
3
4
|
import { ViewerLabs } from '../labs/viewerLabs';
|
|
4
5
|
import { ObservablesManager } from '../managers/observablesManager';
|
package/managers/sceneManager.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { getConfigurationKey } from '../configuration.js';
|
|
1
|
+
import { getConfigurationKey } from '../configuration/configuration.js';
|
|
2
2
|
import { ModelState } from '../model/viewerModel.js';
|
|
3
|
-
import { extendClassWithConfig } from '../helper.js';
|
|
3
|
+
import { extendClassWithConfig, deepmerge } from '../helper/index.js';
|
|
4
4
|
import { ViewerLabs } from '../labs/viewerLabs.js';
|
|
5
|
-
import { getCustomOptimizerByName } from '../optimizer/custom
|
|
6
|
-
import { deepmerge } from '../helper.js';
|
|
5
|
+
import { getCustomOptimizerByName } from '../optimizer/custom/index.js';
|
|
7
6
|
import { Observable } from '@babylonjs/core/Misc/observable.js';
|
|
8
7
|
import { SceneOptimizer, SceneOptimizerOptions } from '@babylonjs/core/Misc/sceneOptimizer.js';
|
|
9
8
|
import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera.js';
|
|
@@ -618,7 +617,7 @@ var SceneManager = /** @class */ (function () {
|
|
|
618
617
|
optimizerOptions.addCustomOptimization(function () {
|
|
619
618
|
return customOptimizer_1(_this);
|
|
620
619
|
}, function () {
|
|
621
|
-
return "Babylon Viewer "
|
|
620
|
+
return "Babylon Viewer ".concat(optimizerConfig.custom, " custom optimization");
|
|
622
621
|
});
|
|
623
622
|
}
|
|
624
623
|
}
|