@babylonjs/viewer 5.0.0-alpha.7 → 5.0.0-beta.2

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.
Files changed (54) hide show
  1. package/configuration/configurationCompatibility.js +1 -1
  2. package/configuration/configurationContainer.js +1 -1
  3. package/configuration/globals.js +1 -1
  4. package/configuration/index.js +2 -2
  5. package/configuration/interfaces/groundConfiguration.js.map +1 -1
  6. package/configuration/interfaces/index.js +15 -15
  7. package/configuration/loader.js +4 -2
  8. package/configuration/loader.js.map +1 -1
  9. package/configuration/mappers.js +2 -2
  10. package/configuration/mappers.js.map +1 -1
  11. package/configuration/renderOnlyLoader.js +6 -6
  12. package/configuration/types/default.js +2 -2
  13. package/configuration/types/extended.js +1 -1
  14. package/configuration/types/index.js +6 -6
  15. package/configuration/types/index.js.map +1 -1
  16. package/helper/index.d.ts +1 -1
  17. package/helper/index.js +1 -1
  18. package/helper/index.js.map +1 -1
  19. package/index.js +13 -13
  20. package/initializer.js +3 -3
  21. package/labs/environmentSerializer.js +3 -3
  22. package/labs/environmentSerializer.js.map +1 -1
  23. package/labs/texture.js +4 -4
  24. package/labs/texture.js.map +1 -1
  25. package/labs/viewerLabs.js +5 -5
  26. package/loader/modelLoader.js +6 -6
  27. package/loader/modelLoader.js.map +1 -1
  28. package/loader/plugins/extendedMaterialLoaderPlugin.js +1 -1
  29. package/loader/plugins/index.js +5 -5
  30. package/loader/plugins/telemetryLoaderPlugin.js +2 -2
  31. package/managers/observablesManager.js +1 -1
  32. package/managers/sceneManager.js +28 -28
  33. package/managers/sceneManager.js.map +1 -1
  34. package/managers/telemetryManager.js +1 -1
  35. package/model/viewerModel.js +11 -11
  36. package/optimizer/custom/extended.js +1 -1
  37. package/optimizer/custom/index.js +1 -1
  38. package/package.json +6 -6
  39. package/renderOnlyIndex.js +11 -11
  40. package/renderOnlyIndex.js.map +1 -1
  41. package/templating/plugins/hdButtonPlugin.js +3 -1
  42. package/templating/plugins/hdButtonPlugin.js.map +1 -1
  43. package/templating/plugins/printButton.js +4 -2
  44. package/templating/plugins/printButton.js.map +1 -1
  45. package/templating/templateManager.js +5 -5
  46. package/templating/templateManager.js.map +1 -1
  47. package/viewer/defaultViewer.js +13 -11
  48. package/viewer/defaultViewer.js.map +1 -1
  49. package/viewer/renderOnlyViewer.js +3 -1
  50. package/viewer/renderOnlyViewer.js.map +1 -1
  51. package/viewer/viewer.js +14 -14
  52. package/viewer/viewerManager.js +1 -1
  53. package/viewer/viewerWithTemplate.js +4 -2
  54. package/viewer/viewerWithTemplate.js.map +1 -1
@@ -1,4 +1,4 @@
1
- import { getConfigurationKey } from './configuration';
1
+ import { getConfigurationKey } from './configuration.js';
2
2
  /**
3
3
  * This function will make sure the configuration file is taking deprecated fields into account
4
4
  * and is setting them to the correct keys and values.
@@ -1,4 +1,4 @@
1
- import { Color3 } from '@babylonjs/core/Maths/math';
1
+ import { Color3 } from '@babylonjs/core/Maths/math.js';
2
2
  var ConfigurationContainer = /** @class */ (function () {
3
3
  function ConfigurationContainer() {
4
4
  this.mainColor = Color3.White();
@@ -1,4 +1,4 @@
1
- import { Engine } from "@babylonjs/core/Engines/engine";
1
+ import { Engine } from "@babylonjs/core/Engines/engine.js";
2
2
  var ViewerGlobals = /** @class */ (function () {
3
3
  function ViewerGlobals() {
4
4
  this.disableInit = false;
@@ -1,3 +1,3 @@
1
- export * from './configuration';
2
- export * from './interfaces';
1
+ export * from './configuration.js';
2
+ export * from './interfaces.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"groundConfiguration.js","sourceRoot":"","sources":["../../../../../sourceES6/viewer/src/configuration/interfaces/groundConfiguration.ts"],"names":[],"mappings":"","sourcesContent":["export interface IGroundConfiguration {\r\n size?: number;\r\n receiveShadows?: boolean;\r\n shadowLevel?: number;\r\n /** @deprecated */ shadowOnly?: boolean; \r\n mirror?: boolean | {\r\n sizeRatio?: number;\r\n blurKernel?: number;\r\n amount?: number;\r\n fresnelWeight?: number;\r\n fallOffDistance?: number;\r\n textureType?: number;\r\n };\r\n texture?: string;\r\n color?: { r: number, g: number, b: number };\r\n opacity?: number;\r\n material?: {\r\n [propName: string]: any;\r\n };\r\n}"]}
1
+ {"version":3,"file":"groundConfiguration.js","sourceRoot":"","sources":["../../../../../sourceES6/viewer/src/configuration/interfaces/groundConfiguration.ts"],"names":[],"mappings":"","sourcesContent":["export interface IGroundConfiguration {\r\n size?: number;\r\n receiveShadows?: boolean;\r\n shadowLevel?: number;\r\n /** @deprecated */ shadowOnly?: boolean;\r\n mirror?: boolean | {\r\n sizeRatio?: number;\r\n blurKernel?: number;\r\n amount?: number;\r\n fresnelWeight?: number;\r\n fallOffDistance?: number;\r\n textureType?: number;\r\n };\r\n texture?: string;\r\n color?: { r: number, g: number, b: number };\r\n opacity?: number;\r\n material?: {\r\n [propName: string]: any;\r\n };\r\n}"]}
@@ -1,16 +1,16 @@
1
- export * from './cameraConfiguration';
2
- export * from './colorGradingConfiguration';
3
- export * from './defaultRenderingPipelineConfiguration';
4
- export * from './groundConfiguration';
5
- export * from './imageProcessingConfiguration';
6
- export * from './lightConfiguration';
7
- export * from './modelAnimationConfiguration';
8
- export * from './modelConfiguration';
9
- export * from './observersConfiguration';
10
- export * from './sceneConfiguration';
11
- export * from './sceneOptimizerConfiguration';
12
- export * from './skyboxConfiguration';
13
- export * from './templateConfiguration';
14
- export * from './vrConfiguration';
15
- export * from './environmentMapConfiguration';
1
+ export * from './cameraConfiguration.js';
2
+ export * from './colorGradingConfiguration.js';
3
+ export * from './defaultRenderingPipelineConfiguration.js';
4
+ export * from './groundConfiguration.js';
5
+ export * from './imageProcessingConfiguration.js';
6
+ export * from './lightConfiguration.js';
7
+ export * from './modelAnimationConfiguration.js';
8
+ export * from './modelConfiguration.js';
9
+ export * from './observersConfiguration.js';
10
+ export * from './sceneConfiguration.js';
11
+ export * from './sceneOptimizerConfiguration.js';
12
+ export * from './skyboxConfiguration.js';
13
+ export * from './templateConfiguration.js';
14
+ export * from './vrConfiguration.js';
15
+ export * from './environmentMapConfiguration.js';
16
16
  //# sourceMappingURL=index.js.map
@@ -6,13 +6,15 @@ var __extends = (this && this.__extends) || (function () {
6
6
  return extendStatics(d, b);
7
7
  };
8
8
  return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
9
11
  extendStatics(d, b);
10
12
  function __() { this.constructor = d; }
11
13
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
14
  };
13
15
  })();
14
- import { RenderOnlyConfigurationLoader } from "./renderOnlyLoader";
15
- import { getConfigurationType } from "./types";
16
+ import { RenderOnlyConfigurationLoader } from "./renderOnlyLoader.js";
17
+ import { getConfigurationType } from "./types.js";
16
18
  var ConfigurationLoader = /** @class */ (function (_super) {
17
19
  __extends(ConfigurationLoader, _super);
18
20
  function ConfigurationLoader() {
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/configuration/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C;IAAyC,uCAA6B;IAAtE;;IAIA,CAAC;IAHa,+CAAiB,GAA3B,UAA4B,IAAqB;QAC7C,OAAO,oBAAoB,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;IACpD,CAAC;IACL,0BAAC;AAAD,CAAC,AAJD,CAAyC,6BAA6B,GAIrE","sourcesContent":["import { RenderOnlyConfigurationLoader } from \"./renderOnlyLoader\";\r\nimport { getConfigurationType } from \"./types\";\r\n\r\nexport class ConfigurationLoader extends RenderOnlyConfigurationLoader {\r\n protected getExtendedConfig(type:string|undefined){\r\n return getConfigurationType(type || \"extended\");\r\n }\r\n}"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/configuration/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C;IAAyC,uCAA6B;IAAtE;;IAIA,CAAC;IAHa,+CAAiB,GAA3B,UAA4B,IAAwB;QAChD,OAAO,oBAAoB,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;IACpD,CAAC;IACL,0BAAC;AAAD,CAAC,AAJD,CAAyC,6BAA6B,GAIrE","sourcesContent":["import { RenderOnlyConfigurationLoader } from \"./renderOnlyLoader\";\r\nimport { getConfigurationType } from \"./types\";\r\n\r\nexport class ConfigurationLoader extends RenderOnlyConfigurationLoader {\r\n protected getExtendedConfig(type: string | undefined) {\r\n return getConfigurationType(type || \"extended\");\r\n }\r\n}"]}
@@ -1,5 +1,5 @@
1
- import { Tools } from '@babylonjs/core/Misc/tools';
2
- import { kebabToCamel } from '../helper/';
1
+ import { Tools } from '@babylonjs/core/Misc/tools.js';
2
+ import { kebabToCamel } from '../helper/.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,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS1C;;;;;;;;;;;;;;;;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;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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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C;AAED;;;GAGG;AACH;IAQI;QACI,IAAI,CAAC,QAAQ,GAAG;YACZ,MAAM,EAAE,IAAI,UAAU,EAAE;YACxB,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,9 +1,9 @@
1
- import { mapperManager } from './mappers';
2
- import { processConfigurationCompatibility } from './configurationCompatibility';
3
- import { deepmerge } from '../helper';
4
- import { Tools } from '@babylonjs/core/Misc/tools';
5
- import { extendedConfiguration } from './types/extended';
6
- import { renderOnlyDefaultConfiguration } from './types/renderOnlyDefault';
1
+ import { mapperManager } from './mappers.js';
2
+ import { processConfigurationCompatibility } from './configurationCompatibility.js';
3
+ import { deepmerge } from '../helper.js';
4
+ import { Tools } from '@babylonjs/core/Misc/tools.js';
5
+ import { extendedConfiguration } from './types/extended.js';
6
+ import { renderOnlyDefaultConfiguration } from './types/renderOnlyDefault.js';
7
7
  /**
8
8
  * The configuration loader will load the configuration object from any source and will use the defined mapper to
9
9
  * parse the object and return a conform ViewerConfiguration.
@@ -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
- import { renderOnlyDefaultConfiguration } from './renderOnlyDefault';
4
- import { deepmerge } from '../../helper';
3
+ import { renderOnlyDefaultConfiguration } from './renderOnlyDefault.js';
4
+ import { deepmerge } from '../../helper.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,4 +1,4 @@
1
- import { Tools } from '@babylonjs/core/Misc/tools';
1
+ import { Tools } from '@babylonjs/core/Misc/tools.js';
2
2
  /**
3
3
  * The viewer's "extended" configuration.
4
4
  * This configuration defines specific objects and parameters that we think make any model look good.
@@ -1,9 +1,9 @@
1
- import { minimalConfiguration } from './minimal';
2
- import { defaultConfiguration } from './default';
3
- import { extendedConfiguration } from './extended';
4
- import { shadowDirectionalLightConfiguration, shadowSpotlLightConfiguration } from './shadowLight';
5
- import { environmentMapConfiguration } from './environmentMap';
6
- import { deepmerge } from '../../helper/';
1
+ import { minimalConfiguration } from './minimal.js';
2
+ import { defaultConfiguration } from './default.js';
3
+ import { extendedConfiguration } from './extended.js';
4
+ import { shadowDirectionalLightConfiguration, shadowSpotlLightConfiguration } from './shadowLight.js';
5
+ import { environmentMapConfiguration } from './environmentMap.js';
6
+ import { deepmerge } from '../../helper/.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,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;;;GAOG;AACH,IAAI,oBAAoB,GAAG,UAAS,KAAa;IAC7C,IAAI,MAAM,GAAwB,EAAE,CAAC;IACrC,IAAI,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,cAAc,CAAC,OAAO,CAAC,UAAC,IAAI;QACxB,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE;YACjB,KAAK,gBAAgB;gBACjB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;gBACxD,MAAM;YACV,KAAK,wBAAwB;gBACzB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;gBAChE,MAAM;YACV,KAAK,iBAAiB;gBAClB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;gBAC1D,MAAM;YACV,KAAK,SAAS;gBACV,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;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/';\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
+ {"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,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;;;GAOG;AACH,IAAI,oBAAoB,GAAG,UAAU,KAAa;IAC9C,IAAI,MAAM,GAAwB,EAAE,CAAC;IACrC,IAAI,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,cAAc,CAAC,OAAO,CAAC,UAAC,IAAI;QACxB,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE;YACjB,KAAK,gBAAgB;gBACjB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;gBACxD,MAAM;YACV,KAAK,wBAAwB;gBACzB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;gBAChE,MAAM;YACV,KAAK,iBAAiB;gBAClB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;gBAC1D,MAAM;YACV,KAAK,SAAS;gBACV,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;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/';\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 };"]}
package/helper/index.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare function camelToKebab(str: any): any;
19
19
  /**
20
20
  * This will extend an object with configuration values.
21
21
  * What it practically does it take the keys from the configuration and set them on the object.
22
- * I the configuration is a tree, it will traverse into the tree.
22
+ * If the configuration is a tree, it will traverse into the tree.
23
23
  * @param object the object to extend
24
24
  * @param config the configuration object that will extend the object
25
25
  */
package/helper/index.js CHANGED
@@ -30,7 +30,7 @@ export function camelToKebab(str) {
30
30
  /**
31
31
  * This will extend an object with configuration values.
32
32
  * What it practically does it take the keys from the configuration and set them on the object.
33
- * I the configuration is a tree, it will traverse into the tree.
33
+ * If the configuration is a tree, it will traverse into the tree.
34
34
  * @param object the object to extend
35
35
  * @param config the configuration object that will extend the object
36
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAEvC,IAAI,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC;AAE9B;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,UAAkB;IACpC,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACxI,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,CAAC;IAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,UAAS,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,uDAAuD;AACvD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAG;IAC5B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,UAAS,CAAC,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAW,EAAE,MAAW;IAC1D,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAAE,OAAO;KAAE;IACtD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAS,GAAG;QACpC,IAAI,GAAG,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE;YACpD,iDAAiD;YACjD,oEAAoE;YACpE,6GAA6G;YAC7G,IAAI,CAAC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,EAAE;gBAChG,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;aACnD;iBAAM;gBACH,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;oBAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;iBAC7B;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import * as deepmerge from 'deepmerge';\r\n\r\nlet expDm = deepmerge['default'];\r\nexport { expDm as deepmerge };\r\n\r\n/**\r\n * Is the provided string a URL?\r\n *\r\n * @param urlToCheck the url to inspect\r\n */\r\nexport function isUrl(urlToCheck: string): boolean {\r\n if (urlToCheck.indexOf('http') === 0 || urlToCheck.indexOf('/') === 0 || urlToCheck.indexOf('./') === 0 || urlToCheck.indexOf('../') === 0) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Convert a string from kebab-case to camelCase\r\n * @param s string to convert\r\n */\r\nexport function kebabToCamel(s) {\r\n return s.replace(/(\\-\\w)/g, function(m) { return m[1].toUpperCase(); });\r\n}\r\n\r\n//https://gist.github.com/youssman/745578062609e8acac9f\r\n/**\r\n * Convert a string from camelCase to kebab-case\r\n * @param str string to convert\r\n */\r\nexport function camelToKebab(str) {\r\n return !str ? null : str.replace(/([A-Z])/g, function(g) { return '-' + g[0].toLowerCase(); });\r\n}\r\n\r\n/**\r\n * This will extend an object with configuration values.\r\n * What it practically does it take the keys from the configuration and set them on the object.\r\n * I the configuration is a tree, it will traverse into the tree.\r\n * @param object the object to extend\r\n * @param config the configuration object that will extend the object\r\n */\r\nexport function extendClassWithConfig(object: any, config: any) {\r\n if (!config || typeof config !== 'object') { return; }\r\n Object.keys(config).forEach(function(key) {\r\n if (key in object && typeof object[key] !== 'function') {\r\n // if (typeof object[key] === 'function') return;\r\n // if it is an object, iterate internally until reaching basic types\r\n // but null is an object so if its null and config[key] is not an object eg. number, the number should be set\r\n if ((typeof object[key] === 'object') && (object[key] !== null || typeof config[key] === \"object\")) {\r\n extendClassWithConfig(object[key], config[key]);\r\n } else {\r\n if (config[key] !== undefined) {\r\n object[key] = config[key];\r\n }\r\n }\r\n }\r\n });\r\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAEvC,IAAI,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC;AAE9B;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,UAAkB;IACpC,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACxI,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;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AAC;iBAC7B;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import * as deepmerge from 'deepmerge';\r\n\r\nlet expDm = deepmerge['default'];\r\nexport { expDm as deepmerge };\r\n\r\n/**\r\n * Is the provided string a URL?\r\n *\r\n * @param urlToCheck the url to inspect\r\n */\r\nexport function isUrl(urlToCheck: string): boolean {\r\n if (urlToCheck.indexOf('http') === 0 || urlToCheck.indexOf('/') === 0 || urlToCheck.indexOf('./') === 0 || urlToCheck.indexOf('../') === 0) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Convert a string from kebab-case to camelCase\r\n * @param s string to convert\r\n */\r\nexport function kebabToCamel(s) {\r\n return s.replace(/(\\-\\w)/g, function (m) { return m[1].toUpperCase(); });\r\n}\r\n\r\n//https://gist.github.com/youssman/745578062609e8acac9f\r\n/**\r\n * Convert a string from camelCase to kebab-case\r\n * @param str string to convert\r\n */\r\nexport function camelToKebab(str) {\r\n return !str ? null : str.replace(/([A-Z])/g, function (g) { return '-' + g[0].toLowerCase(); });\r\n}\r\n\r\n/**\r\n * This will extend an object with configuration values.\r\n * What it practically does it take the keys from the configuration and set them on the object.\r\n * If the configuration is a tree, it will traverse into the tree.\r\n * @param object the object to extend\r\n * @param config the configuration object that will extend the object\r\n */\r\nexport function extendClassWithConfig(object: any, config: any) {\r\n if (!config || typeof config !== 'object') { return; }\r\n Object.keys(config).forEach(function (key) {\r\n if (key in object && typeof object[key] !== 'function') {\r\n // if (typeof object[key] === 'function') return;\r\n // if it is an object, iterate internally until reaching basic types\r\n // but null is an object so if its null and config[key] is not an object eg. number, the number should be set\r\n if ((typeof object[key] === 'object') && (object[key] !== null || typeof config[key] === \"object\")) {\r\n extendClassWithConfig(object[key], config[key]);\r\n } else {\r\n if (config[key] !== undefined) {\r\n object[key] = config[key];\r\n }\r\n }\r\n }\r\n });\r\n}\r\n"]}
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { mapperManager } from './configuration/mappers';
2
- import { viewerGlobals } from './configuration/globals';
3
- import { viewerManager } from './viewer/viewerManager';
4
- import { DefaultViewer } from './viewer/defaultViewer';
5
- import { AbstractViewer } from './viewer/viewer';
6
- import { telemetryManager } from './managers/telemetryManager';
7
- import { ModelLoader } from './loader/modelLoader';
8
- import { ViewerModel, ModelState } from './model/viewerModel';
9
- import { AnimationPlayMode, AnimationState } from './model/modelAnimation';
10
- import { AbstractViewerNavbarButton } from './templating/viewerTemplatePlugin';
11
- import { registerCustomOptimizer } from './optimizer/custom';
1
+ import { mapperManager } from './configuration/mappers.js';
2
+ import { viewerGlobals } from './configuration/globals.js';
3
+ import { viewerManager } from './viewer/viewerManager.js';
4
+ import { DefaultViewer } from './viewer/defaultViewer.js';
5
+ import { AbstractViewer } from './viewer/viewer.js';
6
+ import { telemetryManager } from './managers/telemetryManager.js';
7
+ import { ModelLoader } from './loader/modelLoader.js';
8
+ import { ViewerModel, ModelState } from './model/viewerModel.js';
9
+ import { AnimationPlayMode, AnimationState } from './model/modelAnimation.js';
10
+ import { AbstractViewerNavbarButton } from './templating/viewerTemplatePlugin.js';
11
+ import { registerCustomOptimizer } from './optimizer/custom.js';
12
12
  /**
13
13
  * BabylonJS Viewer
14
14
  *
@@ -18,7 +18,7 @@ import * as BABYLON from '@babylonjs/core';
18
18
  // load needed modules.
19
19
  import '@babylonjs/loaders';
20
20
  import 'pepjs';
21
- import { initListeners, InitTags } from './initializer';
21
+ import { initListeners, InitTags } from './initializer.js';
22
22
  // promise polyfill, if needed!
23
23
  BABYLON.PromisePolyfill.Apply();
24
24
  initListeners();
@@ -38,5 +38,5 @@ console.log("Babylon.js viewer (v" + Version + ")");
38
38
  export { BABYLON, Version, InitTags, DefaultViewer, AbstractViewer, viewerGlobals, telemetryManager, disableInit, viewerManager, mapperManager, disposeAll, ModelLoader, ViewerModel, AnimationPlayMode, AnimationState, ModelState, AbstractViewerNavbarButton, registerCustomOptimizer };
39
39
  export { GLTF2 } from '@babylonjs/loaders';
40
40
  // export publicliy all configuration interfaces
41
- export * from './configuration';
41
+ export * from './configuration.js';
42
42
  //# sourceMappingURL=index.js.map
package/initializer.js CHANGED
@@ -1,6 +1,6 @@
1
- import { DefaultViewer } from './viewer/defaultViewer';
2
- import { mapperManager } from './configuration/mappers';
3
- import { viewerGlobals } from './configuration/globals';
1
+ import { DefaultViewer } from './viewer/defaultViewer.js';
2
+ import { mapperManager } from './configuration/mappers.js';
3
+ import { viewerGlobals } from './configuration/globals.js';
4
4
  /**
5
5
  * Will attach an init function the the DOMContentLoaded event.
6
6
  * The init function will be removed automatically after the event was triggered.
@@ -1,6 +1,6 @@
1
- import { Vector3 } from '@babylonjs/core/Maths/math';
2
- import { Tools } from '@babylonjs/core/Misc/tools';
3
- import { TextureCube } from './texture';
1
+ import { Vector3 } from '@babylonjs/core/Maths/math.js';
2
+ import { Tools } from '@babylonjs/core/Misc/tools.js';
3
+ import { TextureCube } from './texture.js';
4
4
  /**
5
5
  * A static class proving methods to aid parsing Spectre environment files
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"environmentSerializer.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/labs/environmentSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAA0B,MAAM,WAAW,CAAC;AAkHhE;;GAEG;AACH;IAAA;IAqNA,CAAC;IAnNG;;;;OAIG;IACW,6BAAK,GAAnB,UAAoB,WAAwB;QACxC,IAAI,WAAW,GAAmB;YAC9B,YAAY;YACZ,gCAAgC,EAAE;gBAC9B,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACvB,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACvB,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC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AAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QACjC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;IACpC,CAAC;IACL,8BAAC;AAAD,CAAC,AArND,IAqNC","sourcesContent":["import { Vector3 } from '@babylonjs/core/Maths/math';\r\nimport { Tools } from '@babylonjs/core/Misc/tools';\r\nimport { TextureCube, PixelFormat, PixelType } from './texture';\r\n\r\n/**\r\n * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)\r\n * @ignoreChildren\r\n */\r\nexport interface SphericalPolynomalCoefficients {\r\n x: Vector3;\r\n y: Vector3;\r\n z: Vector3;\r\n xx: Vector3;\r\n yy: Vector3;\r\n zz: Vector3;\r\n yz: Vector3;\r\n zx: Vector3;\r\n xy: Vector3;\r\n}\r\n\r\n/**\r\n * Wraps data and maps required for environments with physically based rendering\r\n */\r\nexport interface PBREnvironment {\r\n\r\n /**\r\n * Spherical Polynomial Coefficients representing an irradiance map\r\n */\r\n irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;\r\n\r\n /**\r\n * Specular cubemap\r\n */\r\n specularTexture?: TextureCube;\r\n /**\r\n * A scale factor applied to RGB values after reading from environment maps\r\n */\r\n textureIntensityScale: number;\r\n}\r\n\r\n/**\r\n\t\t * Environment map representations: layouts, projections and approximations\r\n\t\t */\r\nexport type MapType =\r\n 'irradiance_sh_coefficients_9' |\r\n 'cubemap_faces';\r\n\r\n/**\r\n * Image type used for environment map\r\n */\r\nexport type ImageType = 'png';\r\n\r\n//Payload Descriptor\r\n\r\n/**\r\n * A generic field in JSON that report's its type\r\n */\r\nexport interface TypedObject<T> {\r\n type: T;\r\n}\r\n\r\n/**\r\n * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1\r\n */\r\nexport interface ByteRange {\r\n pos: number;\r\n length: number;\r\n}\r\n\r\n/**\r\n * Complete Spectre Environment JSON Descriptor\r\n */\r\nexport interface EnvJsonDescriptor {\r\n radiance: TypedObject<MapType>;\r\n irradiance: TypedObject<MapType>;\r\n specular: TypedObject<MapType>;\r\n}\r\n\r\n/**\r\n * Spherical harmonic coefficients to provide an irradiance map\r\n */\r\nexport interface IrradianceSHCoefficients9 extends TypedObject<MapType> {\r\n l00: Array<number>;\r\n\r\n l1_1: Array<number>;\r\n l10: Array<number>;\r\n l11: Array<number>;\r\n\r\n l2_2: Array<number>;\r\n l2_1: Array<number>;\r\n l20: Array<number>;\r\n l21: Array<number>;\r\n l22: Array<number>;\r\n}\r\n\r\n/**\r\n * A generic set of images, where the image content is specified by byte ranges in the mipmaps field\r\n */\r\nexport interface ImageSet<T> extends TypedObject<MapType> {\r\n imageType: ImageType;\r\n width: number;\r\n height: number;\r\n mipmaps: Array<T>;\r\n multiplier: number;\r\n}\r\n\r\n/**\r\n * A set of cubemap faces\r\n */\r\nexport type CubemapFaces = ImageSet<Array<ByteRange>>;\r\n\r\n/**\r\n * A single image containing an atlas of equirectangular-projection maps across all mip levels\r\n */\r\nexport type EquirectangularMipmapAtlas = ImageSet<ByteRange>;\r\n\r\n/**\r\n * A static class proving methods to aid parsing Spectre environment files\r\n */\r\nexport class EnvironmentDeserializer {\r\n\r\n /**\r\n * Parses an arraybuffer into a new PBREnvironment object\r\n * @param arrayBuffer The arraybuffer of the Spectre environment file\r\n * @return a PBREnvironment object\r\n */\r\n public static Parse(arrayBuffer: ArrayBuffer): PBREnvironment {\r\n var environment: PBREnvironment = {\r\n //irradiance\r\n irradiancePolynomialCoefficients: {\r\n x: new Vector3(0, 0, 0),\r\n y: new Vector3(0, 0, 0),\r\n z: new Vector3(0, 0, 0),\r\n xx: new Vector3(0, 0, 0),\r\n yy: new Vector3(0, 0, 0),\r\n zz: new Vector3(0, 0, 0),\r\n yz: new Vector3(0, 0, 0),\r\n zx: new Vector3(0, 0, 0),\r\n xy: new Vector3(0, 0, 0)\r\n },\r\n\r\n //specular\r\n textureIntensityScale: 1.0,\r\n };\r\n\r\n //read .env\r\n let littleEndian = false;\r\n\r\n let magicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n let dataView = new DataView(arrayBuffer);\r\n let pos = 0;\r\n\r\n for (let i = 0; i < magicBytes.length; i++) {\r\n if (dataView.getUint8(pos++) !== magicBytes[i]) {\r\n Tools.Error('Not a Spectre environment map');\r\n }\r\n }\r\n\r\n let version = dataView.getUint16(pos, littleEndian); pos += 2;\r\n\r\n if (version !== 1) {\r\n Tools.Warn('Unsupported Spectre environment map version \"' + version + '\"');\r\n }\r\n\r\n //read json descriptor - collect characters up to null terminator\r\n let descriptorString = '';\r\n let charCode = 0x00;\r\n while ((charCode = dataView.getUint8(pos++))) {\r\n descriptorString += String.fromCharCode(charCode);\r\n }\r\n\r\n let descriptor: EnvJsonDescriptor = JSON.parse(descriptorString);\r\n\r\n let payloadPos = pos;\r\n\r\n //irradiance\r\n switch (descriptor.irradiance.type) {\r\n case 'irradiance_sh_coefficients_9':\r\n //irradiance\r\n let harmonics = <IrradianceSHCoefficients9>descriptor.irradiance;\r\n\r\n EnvironmentDeserializer._ConvertSHIrradianceToLambertianRadiance(harmonics);\r\n\r\n //harmonics now represent radiance\r\n EnvironmentDeserializer._ConvertSHToSP(harmonics, environment.irradiancePolynomialCoefficients);\r\n break;\r\n default:\r\n Tools.Error('Unhandled MapType descriptor.irradiance.type (' + descriptor.irradiance.type + ')');\r\n }\r\n\r\n //specular\r\n switch (descriptor.specular.type) {\r\n case 'cubemap_faces':\r\n\r\n var specularDescriptor = <CubemapFaces>descriptor.specular;\r\n\r\n let specularTexture = environment.specularTexture = new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE);\r\n environment.textureIntensityScale = specularDescriptor.multiplier != null ? specularDescriptor.multiplier : 1.0;\r\n\r\n let mipmaps = specularDescriptor.mipmaps;\r\n let imageType = specularDescriptor.imageType;\r\n\r\n for (let l = 0; l < mipmaps.length; l++) {\r\n let faceRanges = mipmaps[l];\r\n\r\n specularTexture.source[l] = [];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n\r\n let range = faceRanges[i];\r\n let bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);\r\n\r\n switch (imageType) {\r\n case 'png':\r\n\r\n //construct image element from bytes\r\n let image = new Image();\r\n let src = URL.createObjectURL(new Blob([bytes], { type: 'image/png' }));\r\n image.src = src;\r\n specularTexture.source[l][i] = image;\r\n\r\n break;\r\n default:\r\n Tools.Error('Unhandled ImageType descriptor.specular.imageType (' + imageType + ')');\r\n }\r\n }\r\n }\r\n\r\n break;\r\n default:\r\n Tools.Error('Unhandled MapType descriptor.specular.type (' + descriptor.specular.type + ')');\r\n }\r\n\r\n return environment;\r\n }\r\n\r\n /**\r\n * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.\r\n *\t L = (1/pi) * E * rho\r\n *\r\n * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n */\r\n private static _ConvertSHIrradianceToLambertianRadiance(harmonics: any): void {\r\n EnvironmentDeserializer._ScaleSH(harmonics, 1 / Math.PI);\r\n // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied\r\n // (The pixel shader must apply albedo after texture fetches, etc).\r\n }\r\n\r\n /**\r\n * Convert spherical harmonics to spherical polynomial coefficients\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result\r\n */\r\n private static _ConvertSHToSP(harmonics: any, outPolynomialCoefficents: SphericalPolynomalCoefficients) {\r\n const rPi = 1 / Math.PI;\r\n\r\n //x\r\n outPolynomialCoefficents.x.x = 1.02333 * harmonics.l11[0] * rPi;\r\n outPolynomialCoefficents.x.y = 1.02333 * harmonics.l11[1] * rPi;\r\n outPolynomialCoefficents.x.z = 1.02333 * harmonics.l11[2] * rPi;\r\n\r\n outPolynomialCoefficents.y.x = 1.02333 * harmonics.l1_1[0] * rPi;\r\n outPolynomialCoefficents.y.y = 1.02333 * harmonics.l1_1[1] * rPi;\r\n outPolynomialCoefficents.y.z = 1.02333 * harmonics.l1_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.z.x = 1.02333 * harmonics.l10[0] * rPi;\r\n outPolynomialCoefficents.z.y = 1.02333 * harmonics.l10[1] * rPi;\r\n outPolynomialCoefficents.z.z = 1.02333 * harmonics.l10[2] * rPi;\r\n\r\n //xx\r\n outPolynomialCoefficents.xx.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] + 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.xx.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] + 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.xx.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] + 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.yy.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] - 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.yy.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] - 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.yy.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] - 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.zz.x = (0.886277 * harmonics.l00[0] + 0.495417 * harmonics.l20[0]) * rPi;\r\n outPolynomialCoefficents.zz.y = (0.886277 * harmonics.l00[1] + 0.495417 * harmonics.l20[1]) * rPi;\r\n outPolynomialCoefficents.zz.z = (0.886277 * harmonics.l00[2] + 0.495417 * harmonics.l20[2]) * rPi;\r\n\r\n //yz\r\n outPolynomialCoefficents.yz.x = 0.858086 * harmonics.l2_1[0] * rPi;\r\n outPolynomialCoefficents.yz.y = 0.858086 * harmonics.l2_1[1] * rPi;\r\n outPolynomialCoefficents.yz.z = 0.858086 * harmonics.l2_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.zx.x = 0.858086 * harmonics.l21[0] * rPi;\r\n outPolynomialCoefficents.zx.y = 0.858086 * harmonics.l21[1] * rPi;\r\n outPolynomialCoefficents.zx.z = 0.858086 * harmonics.l21[2] * rPi;\r\n\r\n outPolynomialCoefficents.xy.x = 0.858086 * harmonics.l2_2[0] * rPi;\r\n outPolynomialCoefficents.xy.y = 0.858086 * harmonics.l2_2[1] * rPi;\r\n outPolynomialCoefficents.xy.z = 0.858086 * harmonics.l2_2[2] * rPi;\r\n }\r\n\r\n /**\r\n * Multiplies harmonic coefficients in place\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param scaleFactor Value to multiply by\r\n */\r\n private static _ScaleSH(harmonics: any, scaleFactor: number) {\r\n harmonics.l00[0] *= scaleFactor;\r\n harmonics.l00[1] *= scaleFactor;\r\n harmonics.l00[2] *= scaleFactor;\r\n harmonics.l1_1[0] *= scaleFactor;\r\n harmonics.l1_1[1] *= scaleFactor;\r\n harmonics.l1_1[2] *= scaleFactor;\r\n harmonics.l10[0] *= scaleFactor;\r\n harmonics.l10[1] *= scaleFactor;\r\n harmonics.l10[2] *= scaleFactor;\r\n harmonics.l11[0] *= scaleFactor;\r\n harmonics.l11[1] *= scaleFactor;\r\n harmonics.l11[2] *= scaleFactor;\r\n harmonics.l2_2[0] *= scaleFactor;\r\n harmonics.l2_2[1] *= scaleFactor;\r\n harmonics.l2_2[2] *= scaleFactor;\r\n harmonics.l2_1[0] *= scaleFactor;\r\n harmonics.l2_1[1] *= scaleFactor;\r\n harmonics.l2_1[2] *= scaleFactor;\r\n harmonics.l20[0] *= scaleFactor;\r\n harmonics.l20[1] *= scaleFactor;\r\n harmonics.l20[2] *= scaleFactor;\r\n harmonics.l21[0] *= scaleFactor;\r\n harmonics.l21[1] *= scaleFactor;\r\n harmonics.l21[2] *= scaleFactor;\r\n harmonics.l22[0] *= scaleFactor;\r\n harmonics.l22[1] *= scaleFactor;\r\n harmonics.l22[2] *= scaleFactor;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"environmentSerializer.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/labs/environmentSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAA0B,MAAM,WAAW,CAAC;AAkHhE;;G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AC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;IACpC,CAAC;IACL,8BAAC;AAAD,CAAC,AArND,IAqNC","sourcesContent":["import { Vector3 } from '@babylonjs/core/Maths/math';\r\nimport { Tools } from '@babylonjs/core/Misc/tools';\r\nimport { TextureCube, PixelFormat, PixelType } from './texture';\r\n\r\n/**\r\n * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)\r\n * @ignoreChildren\r\n */\r\nexport interface SphericalPolynomalCoefficients {\r\n x: Vector3;\r\n y: Vector3;\r\n z: Vector3;\r\n xx: Vector3;\r\n yy: Vector3;\r\n zz: Vector3;\r\n yz: Vector3;\r\n zx: Vector3;\r\n xy: Vector3;\r\n}\r\n\r\n/**\r\n * Wraps data and maps required for environments with physically based rendering\r\n */\r\nexport interface PBREnvironment {\r\n\r\n /**\r\n * Spherical Polynomial Coefficients representing an irradiance map\r\n */\r\n irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;\r\n\r\n /**\r\n * Specular cubemap\r\n */\r\n specularTexture?: TextureCube;\r\n /**\r\n * A scale factor applied to RGB values after reading from environment maps\r\n */\r\n textureIntensityScale: number;\r\n}\r\n\r\n/**\r\n * Environment map representations: layouts, projections and approximations\r\n */\r\nexport type MapType =\r\n 'irradiance_sh_coefficients_9' |\r\n 'cubemap_faces';\r\n\r\n/**\r\n * Image type used for environment map\r\n */\r\nexport type ImageType = 'png';\r\n\r\n//Payload Descriptor\r\n\r\n/**\r\n * A generic field in JSON that report's its type\r\n */\r\nexport interface TypedObject<T> {\r\n type: T;\r\n}\r\n\r\n/**\r\n * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1\r\n */\r\nexport interface ByteRange {\r\n pos: number;\r\n length: number;\r\n}\r\n\r\n/**\r\n * Complete Spectre Environment JSON Descriptor\r\n */\r\nexport interface EnvJsonDescriptor {\r\n radiance: TypedObject<MapType>;\r\n irradiance: TypedObject<MapType>;\r\n specular: TypedObject<MapType>;\r\n}\r\n\r\n/**\r\n * Spherical harmonic coefficients to provide an irradiance map\r\n */\r\nexport interface IrradianceSHCoefficients9 extends TypedObject<MapType> {\r\n l00: Array<number>;\r\n\r\n l1_1: Array<number>;\r\n l10: Array<number>;\r\n l11: Array<number>;\r\n\r\n l2_2: Array<number>;\r\n l2_1: Array<number>;\r\n l20: Array<number>;\r\n l21: Array<number>;\r\n l22: Array<number>;\r\n}\r\n\r\n/**\r\n * A generic set of images, where the image content is specified by byte ranges in the mipmaps field\r\n */\r\nexport interface ImageSet<T> extends TypedObject<MapType> {\r\n imageType: ImageType;\r\n width: number;\r\n height: number;\r\n mipmaps: Array<T>;\r\n multiplier: number;\r\n}\r\n\r\n/**\r\n * A set of cubemap faces\r\n */\r\nexport type CubemapFaces = ImageSet<Array<ByteRange>>;\r\n\r\n/**\r\n * A single image containing an atlas of equirectangular-projection maps across all mip levels\r\n */\r\nexport type EquirectangularMipmapAtlas = ImageSet<ByteRange>;\r\n\r\n/**\r\n * A static class proving methods to aid parsing Spectre environment files\r\n */\r\nexport class EnvironmentDeserializer {\r\n\r\n /**\r\n * Parses an arraybuffer into a new PBREnvironment object\r\n * @param arrayBuffer The arraybuffer of the Spectre environment file\r\n * @return a PBREnvironment object\r\n */\r\n public static Parse(arrayBuffer: ArrayBuffer): PBREnvironment {\r\n var environment: PBREnvironment = {\r\n //irradiance\r\n irradiancePolynomialCoefficients: {\r\n x: new Vector3(0, 0, 0),\r\n y: new Vector3(0, 0, 0),\r\n z: new Vector3(0, 0, 0),\r\n xx: new Vector3(0, 0, 0),\r\n yy: new Vector3(0, 0, 0),\r\n zz: new Vector3(0, 0, 0),\r\n yz: new Vector3(0, 0, 0),\r\n zx: new Vector3(0, 0, 0),\r\n xy: new Vector3(0, 0, 0)\r\n },\r\n\r\n //specular\r\n textureIntensityScale: 1.0,\r\n };\r\n\r\n //read .env\r\n let littleEndian = false;\r\n\r\n let magicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n let dataView = new DataView(arrayBuffer);\r\n let pos = 0;\r\n\r\n for (let i = 0; i < magicBytes.length; i++) {\r\n if (dataView.getUint8(pos++) !== magicBytes[i]) {\r\n Tools.Error('Not a Spectre environment map');\r\n }\r\n }\r\n\r\n let version = dataView.getUint16(pos, littleEndian); pos += 2;\r\n\r\n if (version !== 1) {\r\n Tools.Warn('Unsupported Spectre environment map version \"' + version + '\"');\r\n }\r\n\r\n //read json descriptor - collect characters up to null terminator\r\n let descriptorString = '';\r\n let charCode = 0x00;\r\n while ((charCode = dataView.getUint8(pos++))) {\r\n descriptorString += String.fromCharCode(charCode);\r\n }\r\n\r\n let descriptor: EnvJsonDescriptor = JSON.parse(descriptorString);\r\n\r\n let payloadPos = pos;\r\n\r\n //irradiance\r\n switch (descriptor.irradiance.type) {\r\n case 'irradiance_sh_coefficients_9':\r\n //irradiance\r\n let harmonics = <IrradianceSHCoefficients9>descriptor.irradiance;\r\n\r\n EnvironmentDeserializer._ConvertSHIrradianceToLambertianRadiance(harmonics);\r\n\r\n //harmonics now represent radiance\r\n EnvironmentDeserializer._ConvertSHToSP(harmonics, environment.irradiancePolynomialCoefficients);\r\n break;\r\n default:\r\n Tools.Error('Unhandled MapType descriptor.irradiance.type (' + descriptor.irradiance.type + ')');\r\n }\r\n\r\n //specular\r\n switch (descriptor.specular.type) {\r\n case 'cubemap_faces':\r\n\r\n var specularDescriptor = <CubemapFaces>descriptor.specular;\r\n\r\n let specularTexture = environment.specularTexture = new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE);\r\n environment.textureIntensityScale = specularDescriptor.multiplier != null ? specularDescriptor.multiplier : 1.0;\r\n\r\n let mipmaps = specularDescriptor.mipmaps;\r\n let imageType = specularDescriptor.imageType;\r\n\r\n for (let l = 0; l < mipmaps.length; l++) {\r\n let faceRanges = mipmaps[l];\r\n\r\n specularTexture.source[l] = [];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n\r\n let range = faceRanges[i];\r\n let bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);\r\n\r\n switch (imageType) {\r\n case 'png':\r\n\r\n //construct image element from bytes\r\n let image = new Image();\r\n let src = URL.createObjectURL(new Blob([bytes], { type: 'image/png' }));\r\n image.src = src;\r\n specularTexture.source[l][i] = image;\r\n\r\n break;\r\n default:\r\n Tools.Error('Unhandled ImageType descriptor.specular.imageType (' + imageType + ')');\r\n }\r\n }\r\n }\r\n\r\n break;\r\n default:\r\n Tools.Error('Unhandled MapType descriptor.specular.type (' + descriptor.specular.type + ')');\r\n }\r\n\r\n return environment;\r\n }\r\n\r\n /**\r\n * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.\r\n *\t L = (1/pi) * E * rho\r\n *\r\n * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n */\r\n private static _ConvertSHIrradianceToLambertianRadiance(harmonics: any): void {\r\n EnvironmentDeserializer._ScaleSH(harmonics, 1 / Math.PI);\r\n // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied\r\n // (The pixel shader must apply albedo after texture fetches, etc).\r\n }\r\n\r\n /**\r\n * Convert spherical harmonics to spherical polynomial coefficients\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result\r\n */\r\n private static _ConvertSHToSP(harmonics: any, outPolynomialCoefficents: SphericalPolynomalCoefficients) {\r\n const rPi = 1 / Math.PI;\r\n\r\n //x\r\n outPolynomialCoefficents.x.x = 1.02333 * harmonics.l11[0] * rPi;\r\n outPolynomialCoefficents.x.y = 1.02333 * harmonics.l11[1] * rPi;\r\n outPolynomialCoefficents.x.z = 1.02333 * harmonics.l11[2] * rPi;\r\n\r\n outPolynomialCoefficents.y.x = 1.02333 * harmonics.l1_1[0] * rPi;\r\n outPolynomialCoefficents.y.y = 1.02333 * harmonics.l1_1[1] * rPi;\r\n outPolynomialCoefficents.y.z = 1.02333 * harmonics.l1_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.z.x = 1.02333 * harmonics.l10[0] * rPi;\r\n outPolynomialCoefficents.z.y = 1.02333 * harmonics.l10[1] * rPi;\r\n outPolynomialCoefficents.z.z = 1.02333 * harmonics.l10[2] * rPi;\r\n\r\n //xx\r\n outPolynomialCoefficents.xx.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] + 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.xx.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] + 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.xx.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] + 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.yy.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] - 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.yy.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] - 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.yy.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] - 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.zz.x = (0.886277 * harmonics.l00[0] + 0.495417 * harmonics.l20[0]) * rPi;\r\n outPolynomialCoefficents.zz.y = (0.886277 * harmonics.l00[1] + 0.495417 * harmonics.l20[1]) * rPi;\r\n outPolynomialCoefficents.zz.z = (0.886277 * harmonics.l00[2] + 0.495417 * harmonics.l20[2]) * rPi;\r\n\r\n //yz\r\n outPolynomialCoefficents.yz.x = 0.858086 * harmonics.l2_1[0] * rPi;\r\n outPolynomialCoefficents.yz.y = 0.858086 * harmonics.l2_1[1] * rPi;\r\n outPolynomialCoefficents.yz.z = 0.858086 * harmonics.l2_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.zx.x = 0.858086 * harmonics.l21[0] * rPi;\r\n outPolynomialCoefficents.zx.y = 0.858086 * harmonics.l21[1] * rPi;\r\n outPolynomialCoefficents.zx.z = 0.858086 * harmonics.l21[2] * rPi;\r\n\r\n outPolynomialCoefficents.xy.x = 0.858086 * harmonics.l2_2[0] * rPi;\r\n outPolynomialCoefficents.xy.y = 0.858086 * harmonics.l2_2[1] * rPi;\r\n outPolynomialCoefficents.xy.z = 0.858086 * harmonics.l2_2[2] * rPi;\r\n }\r\n\r\n /**\r\n * Multiplies harmonic coefficients in place\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param scaleFactor Value to multiply by\r\n */\r\n private static _ScaleSH(harmonics: any, scaleFactor: number) {\r\n harmonics.l00[0] *= scaleFactor;\r\n harmonics.l00[1] *= scaleFactor;\r\n harmonics.l00[2] *= scaleFactor;\r\n harmonics.l1_1[0] *= scaleFactor;\r\n harmonics.l1_1[1] *= scaleFactor;\r\n harmonics.l1_1[2] *= scaleFactor;\r\n harmonics.l10[0] *= scaleFactor;\r\n harmonics.l10[1] *= scaleFactor;\r\n harmonics.l10[2] *= scaleFactor;\r\n harmonics.l11[0] *= scaleFactor;\r\n harmonics.l11[1] *= scaleFactor;\r\n harmonics.l11[2] *= scaleFactor;\r\n harmonics.l2_2[0] *= scaleFactor;\r\n harmonics.l2_2[1] *= scaleFactor;\r\n harmonics.l2_2[2] *= scaleFactor;\r\n harmonics.l2_1[0] *= scaleFactor;\r\n harmonics.l2_1[1] *= scaleFactor;\r\n harmonics.l2_1[2] *= scaleFactor;\r\n harmonics.l20[0] *= scaleFactor;\r\n harmonics.l20[1] *= scaleFactor;\r\n harmonics.l20[2] *= scaleFactor;\r\n harmonics.l21[0] *= scaleFactor;\r\n harmonics.l21[1] *= scaleFactor;\r\n harmonics.l21[2] *= scaleFactor;\r\n harmonics.l22[0] *= scaleFactor;\r\n harmonics.l22[1] *= scaleFactor;\r\n harmonics.l22[2] *= scaleFactor;\r\n }\r\n}\r\n"]}
package/labs/texture.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture";
2
- import { InternalTexture, InternalTextureSource } from "@babylonjs/core/Materials/Textures/internalTexture";
3
- import { Scalar } from "@babylonjs/core/Maths/math.scalar";
4
- import { Texture } from "@babylonjs/core/Materials/Textures/texture";
1
+ import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture.js";
2
+ import { InternalTexture, InternalTextureSource } from "@babylonjs/core/Materials/Textures/internalTexture.js";
3
+ import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
4
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
5
5
  /**
6
6
  * A minimal WebGL cubemap descriptor
7
7
  */