@babylonjs/viewer 7.34.4 → 7.35.0

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 (34) hide show
  1. package/configuration/configuration.js.map +1 -1
  2. package/configuration/configurationCompatibility.js.map +1 -1
  3. package/configuration/mappers.js +2 -1
  4. package/configuration/mappers.js.map +1 -1
  5. package/configuration/renderOnlyLoader.js.map +1 -1
  6. package/configuration/types/index.js.map +1 -1
  7. package/helper/index.js.map +1 -1
  8. package/initializer.js.map +1 -1
  9. package/labs/environmentSerializer.js.map +1 -1
  10. package/labs/texture.js +2 -1
  11. package/labs/texture.js.map +1 -1
  12. package/labs/viewerLabs.js.map +1 -1
  13. package/loader/modelLoader.js.map +1 -1
  14. package/loader/plugins/index.js.map +1 -1
  15. package/loader/plugins/msftLodLoaderPlugin.js.map +1 -1
  16. package/managers/sceneManager.js.map +1 -1
  17. package/managers/telemetryManager.d.ts +1 -1
  18. package/managers/telemetryManager.js.map +1 -1
  19. package/model/modelAnimation.js.map +1 -1
  20. package/model/viewerModel.js.map +1 -1
  21. package/optimizer/custom/extended.js.map +1 -1
  22. package/optimizer/custom/index.js.map +1 -1
  23. package/package.json +5 -5
  24. package/templating/eventManager.js.map +1 -1
  25. package/templating/plugins/hdButtonPlugin.js +2 -1
  26. package/templating/plugins/hdButtonPlugin.js.map +1 -1
  27. package/templating/plugins/printButton.js +2 -1
  28. package/templating/plugins/printButton.js.map +1 -1
  29. package/templating/templateManager.js.map +1 -1
  30. package/templating/viewerTemplatePlugin.js.map +1 -1
  31. package/viewer/defaultViewer.js.map +1 -1
  32. package/viewer/renderOnlyViewer.js.map +1 -1
  33. package/viewer/viewer.js.map +1 -1
  34. package/viewer/viewerManager.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/configuration.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,YAAiB;IAC9D,IAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE;QACtC,OAAO;KACV;SAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YACjC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;SAC5B;KACJ;SAAM;QACH,IAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,OAAO,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,QAAS,CAAC,CAAC,CAAC;KACzE;AACL,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IEnvironmentMapConfiguration } from \"./interfaces/environmentMapConfiguration\";\r\nimport type { EngineOptions } from \"core/Engines/thinEngine\";\r\nimport type { IObserversConfiguration } from \"./interfaces/observersConfiguration\";\r\nimport type { IModelConfiguration } from \"./interfaces/modelConfiguration\";\r\nimport type { ISceneConfiguration } from \"./interfaces/sceneConfiguration\";\r\nimport type { ISceneOptimizerConfiguration } from \"./interfaces/sceneOptimizerConfiguration\";\r\nimport type { ICameraConfiguration } from \"./interfaces/cameraConfiguration\";\r\nimport type { ISkyboxConfiguration } from \"./interfaces/skyboxConfiguration\";\r\nimport type { IGroundConfiguration } from \"./interfaces/groundConfiguration\";\r\nimport type { ILightConfiguration } from \"./interfaces/lightConfiguration\";\r\nimport type { ITemplateConfiguration } from \"./interfaces/templateConfiguration\";\r\nimport type { IVRConfiguration } from \"./interfaces/vrConfiguration\";\r\nimport type { IDefaultRenderingPipelineConfiguration } from \"./interfaces/defaultRenderingPipelineConfiguration\";\r\n\r\nexport function getConfigurationKey(key: string, configObject: any): any {\r\n const splits = key.split(\".\");\r\n\r\n if (splits.length === 0 || !configObject) {\r\n return;\r\n } else if (splits.length === 1) {\r\n if (configObject[key] !== undefined) {\r\n return configObject[key];\r\n }\r\n } else {\r\n const firstKey = splits.shift();\r\n return getConfigurationKey(splits.join(\".\"), configObject[firstKey!]);\r\n }\r\n}\r\n\r\nexport interface ViewerConfiguration {\r\n // configuration version\r\n version?: string;\r\n extends?: string; // is this configuration extending an existing configuration?\r\n\r\n pageUrl?: string; // will be used for sharing and other fun stuff. This is the page showing the model (not the model's url!)\r\n\r\n configuration?:\r\n | string\r\n | {\r\n url?: string;\r\n payload?: any;\r\n mapper?: string; // json (default), html, yaml, xml, etc'. if not provided, file extension will be used.\r\n };\r\n\r\n // names of functions in the window context.\r\n observers?: IObserversConfiguration;\r\n\r\n canvasElement?: string; // if there is a need to override the standard implementation - ID of HTMLCanvasElement\r\n\r\n model?: IModelConfiguration | string;\r\n\r\n scene?: ISceneConfiguration;\r\n optimizer?: ISceneOptimizerConfiguration | boolean;\r\n // at the moment, support only a single camera.\r\n camera?: ICameraConfiguration;\r\n skybox?: boolean | ISkyboxConfiguration;\r\n\r\n ground?: boolean | IGroundConfiguration;\r\n lights?: {\r\n //globalRotation: number,\r\n [name: string]: number | boolean | ILightConfiguration;\r\n };\r\n // engine configuration. optional!\r\n engine?: {\r\n renderInBackground?: boolean;\r\n antialiasing?: boolean;\r\n disableResize?: boolean;\r\n engineOptions?: EngineOptions;\r\n adaptiveQuality?: boolean;\r\n hdEnabled?: boolean;\r\n };\r\n //templateStructure?: ITemplateStructure,\r\n templates?: {\r\n main: ITemplateConfiguration;\r\n [key: string]: ITemplateConfiguration;\r\n };\r\n\r\n customShaders?: {\r\n shaders?: {\r\n [key: string]: string;\r\n };\r\n includes?: {\r\n [key: string]: string;\r\n };\r\n };\r\n\r\n loaderPlugins?: {\r\n extendedMaterial?: boolean;\r\n msftLod?: boolean;\r\n telemetry?: boolean;\r\n minecraft?: boolean;\r\n\r\n [propName: string]: boolean | undefined;\r\n };\r\n\r\n environmentMap?: IEnvironmentMapConfiguration;\r\n\r\n vr?: IVRConfiguration;\r\n \"3dCommerceCertified\"?: boolean;\r\n\r\n // features that are being tested.\r\n // those features' syntax will change and move out!\r\n // Don't use in production (or be ready to make the changes :) )\r\n lab?: {\r\n flashlight?:\r\n | boolean\r\n | {\r\n exponent?: number;\r\n angle?: number;\r\n intensity?: number;\r\n diffuse?: { r: number; g: number; b: number };\r\n specular?: { r: number; g: number; b: number };\r\n };\r\n hideLoadingDelay?: number;\r\n /** @deprecated */\r\n assetsRootURL?: string;\r\n environmentMainColor?: { r: number; g: number; b: number };\r\n /** @deprecated */\r\n environmentMap?: {\r\n /**\r\n * Environment map texture path in relative to the asset folder.\r\n */\r\n texture: string;\r\n\r\n /**\r\n * Default rotation to apply to the environment map.\r\n */\r\n rotationY: number;\r\n\r\n /**\r\n * Tint level of the main color on the environment map.\r\n */\r\n tintLevel: number;\r\n };\r\n defaultRenderingPipelines?: boolean | IDefaultRenderingPipelineConfiguration;\r\n globalLightRotation?: number;\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/configuration.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,YAAiB;IAC9D,IAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACvC,OAAO;IACX,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,IAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,OAAO,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,QAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IEnvironmentMapConfiguration } from \"./interfaces/environmentMapConfiguration\";\r\nimport type { EngineOptions } from \"core/Engines/thinEngine\";\r\nimport type { IObserversConfiguration } from \"./interfaces/observersConfiguration\";\r\nimport type { IModelConfiguration } from \"./interfaces/modelConfiguration\";\r\nimport type { ISceneConfiguration } from \"./interfaces/sceneConfiguration\";\r\nimport type { ISceneOptimizerConfiguration } from \"./interfaces/sceneOptimizerConfiguration\";\r\nimport type { ICameraConfiguration } from \"./interfaces/cameraConfiguration\";\r\nimport type { ISkyboxConfiguration } from \"./interfaces/skyboxConfiguration\";\r\nimport type { IGroundConfiguration } from \"./interfaces/groundConfiguration\";\r\nimport type { ILightConfiguration } from \"./interfaces/lightConfiguration\";\r\nimport type { ITemplateConfiguration } from \"./interfaces/templateConfiguration\";\r\nimport type { IVRConfiguration } from \"./interfaces/vrConfiguration\";\r\nimport type { IDefaultRenderingPipelineConfiguration } from \"./interfaces/defaultRenderingPipelineConfiguration\";\r\n\r\nexport function getConfigurationKey(key: string, configObject: any): any {\r\n const splits = key.split(\".\");\r\n\r\n if (splits.length === 0 || !configObject) {\r\n return;\r\n } else if (splits.length === 1) {\r\n if (configObject[key] !== undefined) {\r\n return configObject[key];\r\n }\r\n } else {\r\n const firstKey = splits.shift();\r\n return getConfigurationKey(splits.join(\".\"), configObject[firstKey!]);\r\n }\r\n}\r\n\r\nexport interface ViewerConfiguration {\r\n // configuration version\r\n version?: string;\r\n extends?: string; // is this configuration extending an existing configuration?\r\n\r\n pageUrl?: string; // will be used for sharing and other fun stuff. This is the page showing the model (not the model's url!)\r\n\r\n configuration?:\r\n | string\r\n | {\r\n url?: string;\r\n payload?: any;\r\n mapper?: string; // json (default), html, yaml, xml, etc'. if not provided, file extension will be used.\r\n };\r\n\r\n // names of functions in the window context.\r\n observers?: IObserversConfiguration;\r\n\r\n canvasElement?: string; // if there is a need to override the standard implementation - ID of HTMLCanvasElement\r\n\r\n model?: IModelConfiguration | string;\r\n\r\n scene?: ISceneConfiguration;\r\n optimizer?: ISceneOptimizerConfiguration | boolean;\r\n // at the moment, support only a single camera.\r\n camera?: ICameraConfiguration;\r\n skybox?: boolean | ISkyboxConfiguration;\r\n\r\n ground?: boolean | IGroundConfiguration;\r\n lights?: {\r\n //globalRotation: number,\r\n [name: string]: number | boolean | ILightConfiguration;\r\n };\r\n // engine configuration. optional!\r\n engine?: {\r\n renderInBackground?: boolean;\r\n antialiasing?: boolean;\r\n disableResize?: boolean;\r\n engineOptions?: EngineOptions;\r\n adaptiveQuality?: boolean;\r\n hdEnabled?: boolean;\r\n };\r\n //templateStructure?: ITemplateStructure,\r\n templates?: {\r\n main: ITemplateConfiguration;\r\n [key: string]: ITemplateConfiguration;\r\n };\r\n\r\n customShaders?: {\r\n shaders?: {\r\n [key: string]: string;\r\n };\r\n includes?: {\r\n [key: string]: string;\r\n };\r\n };\r\n\r\n loaderPlugins?: {\r\n extendedMaterial?: boolean;\r\n msftLod?: boolean;\r\n telemetry?: boolean;\r\n minecraft?: boolean;\r\n\r\n [propName: string]: boolean | undefined;\r\n };\r\n\r\n environmentMap?: IEnvironmentMapConfiguration;\r\n\r\n vr?: IVRConfiguration;\r\n \"3dCommerceCertified\"?: boolean;\r\n\r\n // features that are being tested.\r\n // those features' syntax will change and move out!\r\n // Don't use in production (or be ready to make the changes :) )\r\n lab?: {\r\n flashlight?:\r\n | boolean\r\n | {\r\n exponent?: number;\r\n angle?: number;\r\n intensity?: number;\r\n diffuse?: { r: number; g: number; b: number };\r\n specular?: { r: number; g: number; b: number };\r\n };\r\n hideLoadingDelay?: number;\r\n /** @deprecated */\r\n assetsRootURL?: string;\r\n environmentMainColor?: { r: number; g: number; b: number };\r\n /** @deprecated */\r\n environmentMap?: {\r\n /**\r\n * Environment map texture path in relative to the asset folder.\r\n */\r\n texture: string;\r\n\r\n /**\r\n * Default rotation to apply to the environment map.\r\n */\r\n rotationY: number;\r\n\r\n /**\r\n * Tint level of the main color on the environment map.\r\n */\r\n tintLevel: number;\r\n };\r\n defaultRenderingPipelines?: boolean | IDefaultRenderingPipelineConfiguration;\r\n globalLightRotation?: number;\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"configurationCompatibility.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/configurationCompatibility.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAAC,aAAkC;IAChF,IAAI,aAAa,CAAC,MAAM,EAAE;QACtB,+CAA+C;QAC/C,IAAI,aAAa,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC7C,cAAc,CAAC,aAAa,EAAE,6CAA6C,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SAC/G;QAED,+CAA+C;QAC/C,IAAI,aAAa,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC7C,cAAc,CAAC,aAAa,EAAE,6CAA6C,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SAC/G;KACJ;IAED,IAAI,aAAa,CAAC,KAAK,EAAE;QACrB,MAAM;QACN,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE;YAC1B,cAAc,CAAC,aAAa,EAAE,gDAAgD,EAAE,IAAI,CAAC,CAAC;YACtF,IAAM,iBAAiB,GAAG,mBAAmB,CAAC,8CAA8C,EAAE,aAAa,CAAC,CAAC;YAC7G,IAAI,iBAAiB,KAAK,KAAK,EAAE;gBAC7B,cAAc,CAAC,aAAa,EAAE,8CAA8C,EAAE,IAAI,CAAC,CAAC;aACvF;SACJ;QAED,IAAI,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE;YAC/B,cAAc,CAAC,aAAa,EA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AC,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE;QACnD,OAAO;KACV;IACD,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AAC5B,CAAC","sourcesContent":["import type { ViewerConfiguration } from \"./configuration\";\r\nimport { getConfigurationKey } from \"./configuration\";\r\n/**\r\n * This function will make sure the configuration file is taking deprecated fields into account\r\n * and is setting them to the correct keys and values.\r\n *\r\n * @param configuration The configuration to process. Mutable!\r\n */\r\nexport function processConfigurationCompatibility(configuration: ViewerConfiguration) {\r\n if (configuration.camera) {\r\n // camera contrast -> image processing contrast\r\n if (configuration.camera.contrast !== undefined) {\r\n setKeyInObject(configuration, \"scene.imageProcessingConfiguration.contrast\", configuration.camera.contrast);\r\n }\r\n\r\n // camera exposure -> image processing exposure\r\n if (configuration.camera.exposure !== undefined) {\r\n setKeyInObject(configuration, \"scene.imageProcessingConfiguration.exposure\", configuration.camera.exposure);\r\n }\r\n }\r\n\r\n if (configuration.scene) {\r\n //glow\r\n if (configuration.scene.glow) {\r\n setKeyInObject(configuration, \"lab.defaultRenderingPipelines.glowLayerEnabled\", true);\r\n const enabledProcessing = getConfigurationKey(\"scene.imageProcessingConfiguration.isEnabled\", configuration);\r\n if (enabledProcessing !== false) {\r\n setKeyInObject(configuration, \"scene.imageProcessingConfiguration.isEnabled\", true);\r\n }\r\n }\r\n\r\n if (configuration.scene.mainColor) {\r\n setKeyInObject(configuration, \"environmentMap.mainColor\", configuration.scene.mainColor, true);\r\n }\r\n }\r\n\r\n if (configuration.model && typeof configuration.model === \"object\") {\r\n // castShadows === castShadow\r\n if ((<any>configuration.model).castShadows !== undefined && configuration.model.castShadow === undefined) {\r\n configuration.model.castShadow = (<any>configuration.model).castShadows;\r\n }\r\n }\r\n\r\n if (configuration.lab) {\r\n if (configuration.lab.assetsRootURL) {\r\n setKeyInObject(configuration, \"scene.assetsRootURL\", configuration.lab.assetsRootURL, true);\r\n }\r\n if (configuration.lab.environmentMap) {\r\n setKeyInObject(configuration, \"environmentMap\", configuration.lab.environmentMap, true);\r\n }\r\n }\r\n}\r\n\r\nfunction setKeyInObject(object: any, keys: string, value: any, shouldOverwrite?: boolean) {\r\n const keySplit = keys.split(\".\");\r\n if (keySplit.length === 0) {\r\n return;\r\n }\r\n const lastKey = keySplit.pop();\r\n if (!lastKey) {\r\n return;\r\n }\r\n let curObj = object;\r\n keySplit.forEach((key) => {\r\n curObj[key] = curObj[key] || {};\r\n curObj = curObj[key];\r\n });\r\n if (curObj[lastKey] !== undefined && !shouldOverwrite) {\r\n return;\r\n }\r\n curObj[lastKey] = value;\r\n}\r\n"]}
1
+ {"version":3,"file":"configurationCompatibility.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/configurationCompatibility.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAAC,aAAkC;IAChF,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACvB,+CAA+C;QAC/C,IAAI,aAAa,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC9C,cAAc,CAAC,aAAa,EAAE,6CAA6C,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChH,CAAC;QAED,+CAA+C;QAC/C,IAAI,aAAa,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC9C,cAAc,CAAC,aAAa,EAAE,6CAA6C,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChH,CAAC;IACL,CAAC;IAED,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM;QACN,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAC3B,cAAc,CAAC,aAAa,EAAE,gDAAgD,EAAE,IAAI,CAAC,CAAC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AAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACX,CAAC;IACD,IAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,OAAO;IACX,CAAC;IACD,IAAI,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,CAAC,UAAC,GAAG;QACjB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;QACpD,OAAO;IACX,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AAC5B,CAAC","sourcesContent":["import type { ViewerConfiguration } from \"./configuration\";\r\nimport { getConfigurationKey } from \"./configuration\";\r\n/**\r\n * This function will make sure the configuration file is taking deprecated fields into account\r\n * and is setting them to the correct keys and values.\r\n *\r\n * @param configuration The configuration to process. Mutable!\r\n */\r\nexport function processConfigurationCompatibility(configuration: ViewerConfiguration) {\r\n if (configuration.camera) {\r\n // camera contrast -> image processing contrast\r\n if (configuration.camera.contrast !== undefined) {\r\n setKeyInObject(configuration, \"scene.imageProcessingConfiguration.contrast\", configuration.camera.contrast);\r\n }\r\n\r\n // camera exposure -> image processing exposure\r\n if (configuration.camera.exposure !== undefined) {\r\n setKeyInObject(configuration, \"scene.imageProcessingConfiguration.exposure\", configuration.camera.exposure);\r\n }\r\n }\r\n\r\n if (configuration.scene) {\r\n //glow\r\n if (configuration.scene.glow) {\r\n setKeyInObject(configuration, \"lab.defaultRenderingPipelines.glowLayerEnabled\", true);\r\n const enabledProcessing = getConfigurationKey(\"scene.imageProcessingConfiguration.isEnabled\", configuration);\r\n if (enabledProcessing !== false) {\r\n setKeyInObject(configuration, \"scene.imageProcessingConfiguration.isEnabled\", true);\r\n }\r\n }\r\n\r\n if (configuration.scene.mainColor) {\r\n setKeyInObject(configuration, \"environmentMap.mainColor\", configuration.scene.mainColor, true);\r\n }\r\n }\r\n\r\n if (configuration.model && typeof configuration.model === \"object\") {\r\n // castShadows === castShadow\r\n if ((<any>configuration.model).castShadows !== undefined && configuration.model.castShadow === undefined) {\r\n configuration.model.castShadow = (<any>configuration.model).castShadows;\r\n }\r\n }\r\n\r\n if (configuration.lab) {\r\n if (configuration.lab.assetsRootURL) {\r\n setKeyInObject(configuration, \"scene.assetsRootURL\", configuration.lab.assetsRootURL, true);\r\n }\r\n if (configuration.lab.environmentMap) {\r\n setKeyInObject(configuration, \"environmentMap\", configuration.lab.environmentMap, true);\r\n }\r\n }\r\n}\r\n\r\nfunction setKeyInObject(object: any, keys: string, value: any, shouldOverwrite?: boolean) {\r\n const keySplit = keys.split(\".\");\r\n if (keySplit.length === 0) {\r\n return;\r\n }\r\n const lastKey = keySplit.pop();\r\n if (!lastKey) {\r\n return;\r\n }\r\n let curObj = object;\r\n keySplit.forEach((key) => {\r\n curObj[key] = curObj[key] || {};\r\n curObj = curObj[key];\r\n });\r\n if (curObj[lastKey] !== undefined && !shouldOverwrite) {\r\n return;\r\n }\r\n curObj[lastKey] = value;\r\n}\r\n"]}
@@ -142,7 +142,7 @@ var DOMMapper = /** @class */ (function () {
142
142
  * The MapperManager manages the different implemented mappers.
143
143
  * It allows the user to register new mappers as well and use them to parse their own configuration data
144
144
  */
145
- export var MapperManager = /** @class */ (function () {
145
+ var MapperManager = /** @class */ (function () {
146
146
  function MapperManager() {
147
147
  this._mappers = {
148
148
  html: new HTMLMapper(),
@@ -183,6 +183,7 @@ export var MapperManager = /** @class */ (function () {
183
183
  MapperManager.DefaultMapper = "json";
184
184
  return MapperManager;
185
185
  }());
186
+ export { MapperManager };
186
187
  /**
187
188
  * mapperManager is a singleton of the type MapperManager.
188
189
  * The mapperManager can be disposed directly with calling mapperManager.dispose()
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAGxC,sDAAsD;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS/C;;;;;;;;;;;;;;;;GAgBG;AACH;IAAA;IA+CA,CAAC;IA9CG;;;;OAIG;IACH,wBAAG,GAAH,UAAI,OAAoB;QACpB,IAAM,MAAM,GAAG,EAAE,CAAC;gCACT,OAAO;YACZ,IAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,IAAI,EAAE;;aAEV;YACD,0DAA0D;YAC1D,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACvC,KAAK,CAAC,MAAM,CAAC,UAAC,aAAqC,EAAE,GAAG,EAAE,GAAG;gBACzD,kCAAkC;gBAClC,IAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;gBACnC,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,GAAG,IAAI,CAAC;qBACd;yBAAM,IAAI,GAAG,KAAK,OAAO,EAAE;wBACxB,GAAG,GAAG,KAAK,CAAC;qBACf;yBAAM,IAAI,GAAG,KAAK,WAAW,EAAE;wBAC5B,GAAG,GAAG,SAAS,CAAC;qBACnB;yBAAM,IAAI,GAAG,KAAK,MAAM,EAAE;wBACvB,GAAG,GAAG,IAAI,CAAC;qBACd;yBAAM;wBACH,IAAM,KAAK,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IA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,gBAAC;AAAD,CAAC,AA1CD,IA0CC;AAED;;;GAGG;AACH;IAOI;QACI,IAAI,CAAC,QAAQ,GAAG;YACZ,IAAI,EAAE,IAAI,UAAU,EAAE;YACtB,IAAI,EAAE,IAAI,UAAU,EAAE;YACtB,GAAG,EAAE,IAAI,SAAS,EAAE;SACvB,CAAC;IACN,CAAC;IAED;;;;;OAKG;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;IAzCD;;OAEG;IACW,2BAAa,GAAG,MAAM,CAAC;IAuCzC,oBAAC;CAAA,AA5CD,IA4CC;AAED;;;;GAIG;AACH,MAAM,CAAC,IAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["import { Tools } from \"core/Misc/tools\";\r\nimport type { ViewerConfiguration } from \"./configuration\";\r\n\r\n// eslint-disable-next-line import/no-internal-modules\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 * Map a specific element and get configuration from it\r\n * @param element the HTML element to analyze.\r\n * @returns a ViewerConfiguration object from the provided HTML Element\r\n */\r\n map(element: HTMLElement): ViewerConfiguration {\r\n const config = {};\r\n for (let attrIdx = 0; attrIdx < element.attributes.length; ++attrIdx) {\r\n const 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 const split = attr.nodeName.split(\".\");\r\n split.reduce((currentConfig: { [key: string]: any }, key, idx) => {\r\n //convert html-style to json-style\r\n const 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 const isnum = !isNaN(parseFloat(val)) && isFinite(val); ///^\\d+$/.test(val);\r\n if (isnum) {\r\n const 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 * 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 const htmlMapper = new HTMLMapper();\r\n const config = htmlMapper.map(baseElement);\r\n\r\n const traverseChildren = function (element: HTMLElement, partConfig: any) {\r\n const children = element.children;\r\n if (children.length) {\r\n for (let i = 0; i < children.length; ++i) {\r\n const item = <HTMLElement>children.item(i);\r\n // use the HTML Mapper to read configuration from a single element\r\n const configMapped = htmlMapper.map(item);\r\n const 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 const 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 * 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 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 * @returns the mapper\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 function 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 * 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 const mapperManager = new MapperManager();\r\n"]}
1
+ {"version":3,"file":"mappers.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAGxC,sDAAsD;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS/C;;;;;;;;;;;;;;;;GAgBG;AACH;IAAA;IA+CA,CAAC;IA9CG;;;;OAIG;IACH,wBAAG,GAAH,UAAI,OAAoB;QACpB,IAAM,MAAM,GAAG,EAAE,CAAC;gCACT,OAAO;YACZ,IAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;;YAEZ,CAAC;YACD,0DAA0D;YAC1D,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACvC,KAAK,CAAC,MAAM,CAAC,UAAC,aAAqC,EAAE,GAAG,EAAE,GAAG;gBACzD,kCAAkC;gBAClC,IAAM,QAAQ,GAAG,YAAY,CAAC,G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,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;IAzCD;;OAEG;IACW,2BAAa,GAAG,MAAM,CAAC;IAuCzC,oBAAC;CAAA,AA5CD,IA4CC;SA5CY,aAAa;AA8C1B;;;;GAIG;AACH,MAAM,CAAC,IAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["import { Tools } from \"core/Misc/tools\";\r\nimport type { ViewerConfiguration } from \"./configuration\";\r\n\r\n// eslint-disable-next-line import/no-internal-modules\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 * Map a specific element and get configuration from it\r\n * @param element the HTML element to analyze.\r\n * @returns a ViewerConfiguration object from the provided HTML Element\r\n */\r\n map(element: HTMLElement): ViewerConfiguration {\r\n const config = {};\r\n for (let attrIdx = 0; attrIdx < element.attributes.length; ++attrIdx) {\r\n const 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 const split = attr.nodeName.split(\".\");\r\n split.reduce((currentConfig: { [key: string]: any }, key, idx) => {\r\n //convert html-style to json-style\r\n const 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 const isnum = !isNaN(parseFloat(val)) && isFinite(val); ///^\\d+$/.test(val);\r\n if (isnum) {\r\n const 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 * 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 const htmlMapper = new HTMLMapper();\r\n const config = htmlMapper.map(baseElement);\r\n\r\n const traverseChildren = function (element: HTMLElement, partConfig: any) {\r\n const children = element.children;\r\n if (children.length) {\r\n for (let i = 0; i < children.length; ++i) {\r\n const item = <HTMLElement>children.item(i);\r\n // use the HTML Mapper to read configuration from a single element\r\n const configMapped = htmlMapper.map(item);\r\n const 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 const 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 * 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 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 * @returns the mapper\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 function 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 * 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 const mapperManager = new MapperManager();\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"renderOnlyLoader.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/renderOnlyLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AAEjF,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAG3E;;;;GAIG;AACH;IAKI,uCAAoB,YAA6B;QAA7B,6BAAA,EAAA,oBAA6B;QAA7B,iBAAY,GAAZ,YAAY,CAAiB;QAC7C,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IAC5B,CAAC;IAEO,4EAAoC,GAA5C,UAA6C,KAAa;QAA1D,iBAoBC;QAnBG,IAAI,MAAM,GAAwB,EAAE,CAAC;QACrC,IAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,cAAc,CAAC,OAAO,CAAC,UAAC,IAAI;YACxB,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE;gBACjB,KAAK,SAAS;oBACV,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;oBAC3D,MAAM;gBACV,KAAK,MAAM;oBACP,MAAM;gBACV,KAAK,UAAU,CAAC;gBAChB;oBACI,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;oBAClD,MAAM;aACb;YACD,IAAI,MAAM,CAAC,OAAO,EAAE;gBAChB,MAAM,GAAG,S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G,KAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBACpD,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,CACJ,CAAC;YACF,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IACL,oCAAC;AAAD,CAAC,AAhKD,IAgKC","sourcesContent":["import { mapperManager } from \"./mappers\";\r\nimport type { ViewerConfiguration } from \"./configuration\";\r\nimport { processConfigurationCompatibility } from \"./configurationCompatibility\";\r\n\r\n// eslint-disable-next-line import/no-internal-modules\r\nimport { deepmerge } from \"../helper/index\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { extendedConfiguration } from \"./types/extended\";\r\nimport { renderOnlyDefaultConfiguration } from \"./types/renderOnlyDefault\";\r\nimport type { IFileRequest } from \"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 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 const 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 // eslint-disable-next-line @typescript-eslint/naming-convention\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 let loadedConfig: ViewerConfiguration = deepmerge({}, initConfig);\r\n this._processInitialConfiguration(loadedConfig);\r\n\r\n const extendedConfiguration = this.getExtendedConfig(loadedConfig.extends);\r\n\r\n if (loadedConfig.configuration) {\r\n let mapperType = \"json\";\r\n return Promise.resolve()\r\n .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 const mapper = mapperManager.getMapper(mapperType);\r\n const parsed = deepmerge(mapper.map(data), loadedConfig);\r\n const merged = deepmerge(extendedConfiguration, parsed);\r\n processConfigurationCompatibility(merged);\r\n if (callback) {\r\n callback(merged);\r\n }\r\n return merged;\r\n });\r\n } else {\r\n loadedConfig = deepmerge(extendedConfiguration, loadedConfig);\r\n processConfigurationCompatibility(loadedConfig);\r\n if (callback) {\r\n callback(loadedConfig);\r\n }\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 const 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 const fileRequest = Tools.LoadFile(\r\n url,\r\n (result) => {\r\n const idx = this._loadRequests.indexOf(fileRequest);\r\n if (idx !== -1) {\r\n this._loadRequests.splice(idx, 1);\r\n }\r\n if (this._enableCache) {\r\n cacheReference[url] = result;\r\n }\r\n resolve(result);\r\n },\r\n undefined,\r\n undefined,\r\n false,\r\n (request, error: any) => {\r\n const 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 );\r\n this._loadRequests.push(fileRequest);\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"renderOnlyLoader.js","sourceRoot":"","sources":["../../../../tools/viewer/src/configuration/renderOnlyLoader.ts"],"names":[],"mapp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AAE,KAAU;gBAChB,IAAM,GAAG,GAAG,KAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBACpD,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;oBACb,KAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBACtC,CAAC;gBACD,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,CACJ,CAAC;YACF,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IACL,oCAAC;AAAD,CAAC,AAhKD,IAgKC","sourcesContent":["import { mapperManager } from \"./mappers\";\r\nimport type { ViewerConfiguration } from \"./configuration\";\r\nimport { processConfigurationCompatibility } from \"./configurationCompatibility\";\r\n\r\n// eslint-disable-next-line import/no-internal-modules\r\nimport { deepmerge } from \"../helper/index\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { extendedConfiguration } from \"./types/extended\";\r\nimport { renderOnlyDefaultConfiguration } from \"./types/renderOnlyDefault\";\r\nimport type { IFileRequest } from \"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 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 const 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 // eslint-disable-next-line @typescript-eslint/naming-convention\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 let loadedConfig: ViewerConfiguration = deepmerge({}, initConfig);\r\n this._processInitialConfiguration(loadedConfig);\r\n\r\n const extendedConfiguration = this.getExtendedConfig(loadedConfig.extends);\r\n\r\n if (loadedConfig.configuration) {\r\n let mapperType = \"json\";\r\n return Promise.resolve()\r\n .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 const mapper = mapperManager.getMapper(mapperType);\r\n const parsed = deepmerge(mapper.map(data), loadedConfig);\r\n const merged = deepmerge(extendedConfiguration, parsed);\r\n processConfigurationCompatibility(merged);\r\n if (callback) {\r\n callback(merged);\r\n }\r\n return merged;\r\n });\r\n } else {\r\n loadedConfig = deepmerge(extendedConfiguration, loadedConfig);\r\n processConfigurationCompatibility(loadedConfig);\r\n if (callback) {\r\n callback(loadedConfig);\r\n }\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 const 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 const fileRequest = Tools.LoadFile(\r\n url,\r\n (result) => {\r\n const idx = this._loadRequests.indexOf(fileRequest);\r\n if (idx !== -1) {\r\n this._loadRequests.splice(idx, 1);\r\n }\r\n if (this._enableCache) {\r\n cacheReference[url] = result;\r\n }\r\n resolve(result);\r\n },\r\n undefined,\r\n undefined,\r\n false,\r\n (request, error: any) => {\r\n const 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 );\r\n this._loadRequests.push(fileRequest);\r\n });\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":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D,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;AAClB,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 type { ViewerConfiguration } from \"../configuration\";\r\nimport { shadowDirectionalLightConfiguration, shadowSpotlLightConfiguration } from \"./shadowLight\";\r\nimport { environmentMapConfiguration } from \"./environmentMap\";\r\n// eslint-disable-next-line import/no-internal-modules\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 * @returns the configuration object\r\n */\r\nconst getConfigurationType = function (types: string): ViewerConfiguration {\r\n let config: ViewerConfiguration = {};\r\n const 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\nexport { getConfigurationType, defaultConfiguration, minimalConfiguration };\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../tools/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,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;GAQG;AACH,IAAM,oBAAoB,GAAG,UAAU,KAAa;IAChD,IAAI,MAAM,GAAwB,EAAE,CAAC;IACrC,IAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,cAAc,CAAC,OAAO,CAAC,UAAC,IAAI;QACxB,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YAClB,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;QACd,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACrE,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAClB,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 type { ViewerConfiguration } from \"../configuration\";\r\nimport { shadowDirectionalLightConfiguration, shadowSpotlLightConfiguration } from \"./shadowLight\";\r\nimport { environmentMapConfiguration } from \"./environmentMap\";\r\n// eslint-disable-next-line import/no-internal-modules\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 * @returns the configuration object\r\n */\r\nconst getConfigurationType = function (types: string): ViewerConfiguration {\r\n let config: ViewerConfiguration = {};\r\n const 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\nexport { getConfigurationType, defaultConfiguration, minimalConfiguration };\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../tools/viewer/src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAEvC,IAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC;AAE9B;;;;;GAKG;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;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC;QAClC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,uDAAuD;AACvD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACpC,OAAO,CAAC,GAAG;QACP,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC;YAC/B,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,CAAC,CAAC,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAW,EAAE,MAAW;IAC1D,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QACvC,OAAO;KACV;IACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG;QACrC,IAAI,GAAG,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE;YACpD,iDAAiD;YACjD,oEAAoE;YACpE,6GAA6G;YAC7G,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,EAAE;gBAC9F,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\nconst 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 * @returns true if the string is a URL\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 * @returns the converted string\r\n */\r\nexport function kebabToCamel(s: string) {\r\n return s.replace(/(-\\w)/g, function (m) {\r\n return m[1].toUpperCase();\r\n });\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 * @returns the converted string\r\n */\r\nexport function camelToKebab(str: string) {\r\n return !str\r\n ? null\r\n : str.replace(/([A-Z])/g, function (g) {\r\n return \"-\" + g[0].toLowerCase();\r\n });\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\") {\r\n return;\r\n }\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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../tools/viewer/src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAEvC,IAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,UAAkB;IACpC,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,GAAG,CAAC,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;gBAC/F,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACJ,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;oBAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC9B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import * as deepmerge from \"deepmerge\";\r\n\r\nconst 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 * @returns true if the string is a URL\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 * @returns the converted string\r\n */\r\nexport function kebabToCamel(s: string) {\r\n return s.replace(/(-\\w)/g, function (m) {\r\n return m[1].toUpperCase();\r\n });\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 * @returns the converted string\r\n */\r\nexport function camelToKebab(str: string) {\r\n return !str\r\n ? null\r\n : str.replace(/([A-Z])/g, function (g) {\r\n return \"-\" + g[0].toLowerCase();\r\n });\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\") {\r\n return;\r\n }\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initializer.js","sourceRoot":"","sources":["../../../tools/viewer/src/initializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,aAAa;IACzB,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IACpD,SAAS,IAAI;QACT,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACvD,IAAI,aAAa,CAAC,WAAW,EAAE;YAC3B,OAAO;SACV;QACD,QAAQ,EAAE,CAAC;IACf,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IAA5B,yBAAA,EAAA,oBAA4B;IACjD,IAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACtC,IAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEjC,6BAA6B;QAC7B,IAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACpD,IAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEzC,6DAA6D;QAC7D,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KACtC;AACL,CAAC","sourcesContent":["import { DefaultViewer } from \"./viewer/defaultViewer\";\r\nimport { mapperManager } from \"./configuration/mappers\";\r\nimport { viewerGlobals } from \"./configuration/globals\";\r\n\r\n/**\r\n * Will attach an init function the DOMContentLoaded event.\r\n * The init function will be removed automatically after the event was triggered.\r\n */\r\nexport function initListeners() {\r\n document.addEventListener(\"DOMContentLoaded\", init);\r\n function init() {\r\n document.removeEventListener(\"DOMContentLoaded\", init);\r\n if (viewerGlobals.disableInit) {\r\n return;\r\n }\r\n InitTags();\r\n }\r\n}\r\n\r\n/**\r\n * Select all HTML tags on the page that match the selector and initialize a viewer\r\n *\r\n * @param selector the selector to initialize the viewer on (default is 'babylon')\r\n */\r\nexport function InitTags(selector: string = \"babylon\") {\r\n const elements = document.querySelectorAll(selector);\r\n for (let i = 0; i < elements.length; ++i) {\r\n const element = elements.item(i);\r\n\r\n // get the html configuration\r\n const configMapper = mapperManager.getMapper(\"dom\");\r\n const config = configMapper.map(element);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n new DefaultViewer(element, config);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"initializer.js","sourceRoot":"","sources":["../../../tools/viewer/src/initializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,aAAa;IACzB,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IACpD,SAAS,IAAI;QACT,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACvD,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC;YAC5B,OAAO;QACX,CAAC;QACD,QAAQ,EAAE,CAAC;IACf,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IAA5B,yBAAA,EAAA,oBAA4B;IACjD,IAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACvC,IAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEjC,6BAA6B;QAC7B,IAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACpD,IAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEzC,6DAA6D;QAC7D,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;AACL,CAAC","sourcesContent":["import { DefaultViewer } from \"./viewer/defaultViewer\";\r\nimport { mapperManager } from \"./configuration/mappers\";\r\nimport { viewerGlobals } from \"./configuration/globals\";\r\n\r\n/**\r\n * Will attach an init function the DOMContentLoaded event.\r\n * The init function will be removed automatically after the event was triggered.\r\n */\r\nexport function initListeners() {\r\n document.addEventListener(\"DOMContentLoaded\", init);\r\n function init() {\r\n document.removeEventListener(\"DOMContentLoaded\", init);\r\n if (viewerGlobals.disableInit) {\r\n return;\r\n }\r\n InitTags();\r\n }\r\n}\r\n\r\n/**\r\n * Select all HTML tags on the page that match the selector and initialize a viewer\r\n *\r\n * @param selector the selector to initialize the viewer on (default is 'babylon')\r\n */\r\nexport function InitTags(selector: string = \"babylon\") {\r\n const elements = document.querySelectorAll(selector);\r\n for (let i = 0; i < elements.length; ++i) {\r\n const element = elements.item(i);\r\n\r\n // get the html configuration\r\n const configMapper = mapperManager.getMapper(\"dom\");\r\n const config = configMapper.map(element);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n new DefaultViewer(element, config);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"environmentSerializer.js","sourceRoot":"","sources":["../../../../tools/viewer/src/labs/environmentSerializer.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,sCAAwB;AAC1C,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,WAAW,EAA0B,MAAM,WAAW,CAAC;AA+GhE;;GAEG;AACH;IAAA;IAqNA,CAAC;IApNG;;;;OAIG;IACW,6BAAK,GAAnB,UAAoB,WAAwB;QACxC,IAAM,WAAW,GAAmB;YAChC,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,EAAE,CAAC,EAAE,CAAC,CAAC;gBACvB,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACxB,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACxB,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACxB,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACxB,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;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,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":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector3 } from \"core/Maths/math\";\r\nimport { Tools } from \"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 * 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 = \"irradiance_sh_coefficients_9\" | \"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 * Parses an arraybuffer into a new PBREnvironment object\r\n * @param arrayBuffer The arraybuffer of the Spectre environment file\r\n * @returns a PBREnvironment object\r\n */\r\n public static Parse(arrayBuffer: ArrayBuffer): PBREnvironment {\r\n const 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 const littleEndian = false;\r\n\r\n const magicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n const 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 const version = dataView.getUint16(pos, littleEndian);\r\n 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 const descriptor: EnvJsonDescriptor = JSON.parse(descriptorString);\r\n\r\n const 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 const 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 }\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 const specularDescriptor = <CubemapFaces>descriptor.specular;\r\n\r\n const 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 const mipmaps = specularDescriptor.mipmaps;\r\n const imageType = specularDescriptor.imageType;\r\n\r\n for (let l = 0; l < mipmaps.length; l++) {\r\n const faceRanges = mipmaps[l];\r\n\r\n specularTexture.source[l] = [];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n const range = faceRanges[i];\r\n const bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);\r\n\r\n switch (imageType) {\r\n case \"png\": {\r\n //construct image element from bytes\r\n const image = new Image();\r\n const 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 }\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 }\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":["../../../../tools/viewer/src/labs/environmentSerializer.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,sCAAwB;AAC1C,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,WAAW,EAA0B,MAAM,WAAW,CAAC;AA+GhE;;GAEG;AACH;IAAA;IAqNA,CAAC;IApNG;;;;OAIG;IACW,6BAAK,GAAnB,UAAoB,WAAwB;QACxC,IAAM,WAAW,GAAmB;YAChC,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,IAA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C;IACpC,CAAC;IACL,8BAAC;AAAD,CAAC,AArND,IAqNC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector3 } from \"core/Maths/math\";\r\nimport { Tools } from \"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 * 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 = \"irradiance_sh_coefficients_9\" | \"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 * Parses an arraybuffer into a new PBREnvironment object\r\n * @param arrayBuffer The arraybuffer of the Spectre environment file\r\n * @returns a PBREnvironment object\r\n */\r\n public static Parse(arrayBuffer: ArrayBuffer): PBREnvironment {\r\n const 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 const littleEndian = false;\r\n\r\n const magicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n const 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 const version = dataView.getUint16(pos, littleEndian);\r\n 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 const descriptor: EnvJsonDescriptor = JSON.parse(descriptorString);\r\n\r\n const 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 const 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 }\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 const specularDescriptor = <CubemapFaces>descriptor.specular;\r\n\r\n const 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 const mipmaps = specularDescriptor.mipmaps;\r\n const imageType = specularDescriptor.imageType;\r\n\r\n for (let l = 0; l < mipmaps.length; l++) {\r\n const faceRanges = mipmaps[l];\r\n\r\n specularTexture.source[l] = [];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n const range = faceRanges[i];\r\n const bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);\r\n\r\n switch (imageType) {\r\n case \"png\": {\r\n //construct image element from bytes\r\n const image = new Image();\r\n const 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 }\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 }\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
@@ -96,7 +96,7 @@ export { TextureCube };
96
96
  /**
97
97
  * A static class providing methods to aid working with Bablyon textures.
98
98
  */
99
- export var TextureUtils = /** @class */ (function () {
99
+ var TextureUtils = /** @class */ (function () {
100
100
  function TextureUtils() {
101
101
  }
102
102
  /**
@@ -347,4 +347,5 @@ export var TextureUtils = /** @class */ (function () {
347
347
  TextureUtils.EnvironmentLODOffset = 1.0;
348
348
  return TextureUtils;
349
349
  }());
350
+ export { TextureUtils };
350
351
  //# sourceMappingURL=texture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"texture.js","sourceRoot":"","sources":["../../../../tools/viewer/src/labs/texture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAClE,OAAO,EAAE,eAAe,EAAyB,8DAAgD;AAEjG,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAG1D;;GAEG;AACH,MAAM,CAAN,IAAkB,WAOjB;AAPD,WAAkB,WAAW;IACzB,sEAAwB,CAAA;IACxB,kDAAc,CAAA;IACd,8CAAY,CAAA;IACZ,gDAAa,CAAA;IACb,0DAAkB,CAAA;IAClB,sEAAwB,CAAA;AAC5B,CAAC,EAPiB,WAAW,KAAX,WAAW,QAO5B;AAED;;GAEG;AACH,MAAM,CAAN,IAAkB,SAKjB;AALD,WAAkB,SAAS;IACvB,8DAAsB,CAAA;IACtB,iFAA+B,CAAA;IAC/B,iFAA+B,CAAA;IAC/B,6EAA6B,CAAA;AACjC,CAAC,EALiB,SAAS,KAAT,SAAS,QAK1B;AAED;;GAEG;AACH,MAAM,CAAN,IAAkB,gBAGjB;AAHD,WAAkB,gBAAgB;IAC9B,gEAAgB,CAAA;IAChB,8DAAe,CAAA;AACnB,CAAC,EAHiB,gBAAgB,KAAhB,gBAAgB,QAGjC;AAED;;GAEG;AACH,MAAM,CAAN,IAAkB,gBAOjB;AAPD,WAAkB,gBAAgB;IAC9B,gEAAgB,CAAA;IAChB,8DAAe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AS,oCAAyB;QAClC,SAAS,kDAAuC;QAChD,KAAK,2CAA+B;QACpC,KAAK,2CAA+B;QACpC,aAAa,EAAE,CAAC;KACnB,CAAC;IAEa,0CAA6B,GAAuB;QAC/D,SAAS,oCAAyB;QAClC,SAAS,oCAAyB;QAClC,KAAK,2CAA+B;QACpC,KAAK,2CAA+B;QACpC,aAAa,EAAE,CAAC;KACnB,CAAC;IAEF,gFAAgF;IAChF;;OAEG;IACW,gCAAmB,GAAG,GAAG,CAAC;IACxC;;OAEG;IACW,iCAAoB,GAAG,GAAG,CAAC;IAC7C,mBAAC;CAAA,AAtSD,IAsSC","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport { CubeTexture } from \"core/Materials/Textures/cubeTexture\";\r\nimport { InternalTexture, InternalTextureSource } from \"core/Materials/Textures/internalTexture\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\n/**\r\n * WebGL Pixel Formats\r\n */\r\nexport const enum PixelFormat {\r\n DEPTH_COMPONENT = 0x1902,\r\n ALPHA = 0x1906,\r\n RGB = 0x1907,\r\n RGBA = 0x1908,\r\n LUMINANCE = 0x1909,\r\n LUMINANCE_ALPHA = 0x190a,\r\n}\r\n\r\n/**\r\n * WebGL Pixel Types\r\n */\r\nexport const enum PixelType {\r\n UNSIGNED_BYTE = 0x1401,\r\n UNSIGNED_SHORT_4_4_4_4 = 0x8033,\r\n UNSIGNED_SHORT_5_5_5_1 = 0x8034,\r\n UNSIGNED_SHORT_5_6_5 = 0x8363,\r\n}\r\n\r\n/**\r\n * WebGL Texture Magnification Filter\r\n */\r\nexport const enum TextureMagFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n}\r\n\r\n/**\r\n * WebGL Texture Minification Filter\r\n */\r\nexport const enum TextureMinFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n NEAREST_MIPMAP_NEAREST = 0x2700,\r\n LINEAR_MIPMAP_NEAREST = 0x2701,\r\n NEAREST_MIPMAP_LINEAR = 0x2702,\r\n LINEAR_MIPMAP_LINEAR = 0x2703,\r\n}\r\n\r\n/**\r\n * WebGL Texture Wrap Modes\r\n */\r\nexport const enum TextureWrapMode {\r\n REPEAT = 0x2901,\r\n CLAMP_TO_EDGE = 0x812f,\r\n MIRRORED_REPEAT = 0x8370,\r\n}\r\n\r\n/**\r\n * Raw texture data and descriptor sufficient for WebGL texture upload\r\n */\r\nexport interface TextureData {\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n /**\r\n * Height of image\r\n */\r\n height: number;\r\n /**\r\n * Format of pixels in data\r\n */\r\n format: PixelFormat;\r\n /**\r\n * Row byte alignment of pixels in data\r\n */\r\n alignment: number;\r\n /**\r\n * Pixel data\r\n */\r\n data: ArrayBufferView;\r\n}\r\n\r\n/**\r\n * Wraps sampling parameters for a WebGL texture\r\n */\r\nexport interface SamplingParameters {\r\n /**\r\n * Magnification mode when upsampling from a WebGL texture\r\n */\r\n magFilter?: TextureMagFilter;\r\n /**\r\n * Minification mode when upsampling from a WebGL texture\r\n */\r\n minFilter?: TextureMinFilter;\r\n /**\r\n * X axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapS?: TextureWrapMode;\r\n /**\r\n * Y axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapT?: TextureWrapMode;\r\n /**\r\n * Anisotropic filtering samples\r\n */\r\n maxAnisotropy?: number;\r\n}\r\n\r\n/**\r\n * Represents a valid WebGL texture source for use in texImage2D\r\n */\r\nexport type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;\r\n\r\n/**\r\n * A generic set of texture mipmaps (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps<T> = Array<T>;\r\n\r\n/**\r\n * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]\r\n */\r\nexport type Faces<T> = Array<T>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps2D = Mipmaps<TextureSource>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type MipmapsCube = Mipmaps<Faces<TextureSource>>;\r\n\r\n/**\r\n * A minimal WebGL cubemap descriptor\r\n */\r\nexport class TextureCube {\r\n /**\r\n * Returns the width of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Width(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].width : 0;\r\n }\r\n\r\n /**\r\n * Returns the height of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Height(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].height : 0;\r\n }\r\n\r\n /**\r\n * constructor\r\n * @param internalFormat WebGL pixel format for the texture on the GPU\r\n * @param type WebGL pixel type of the supplied data and texture on the GPU\r\n * @param source An array containing mipmap levels of faces, where each mipmap level is an array of faces and each face is a TextureSource object\r\n */\r\n constructor(\r\n public internalFormat: PixelFormat,\r\n public type: PixelType,\r\n public source: MipmapsCube = []\r\n ) {}\r\n}\r\n\r\n/**\r\n * A static class providing methods to aid working with Bablyon textures.\r\n */\r\nexport class TextureUtils {\r\n /**\r\n * A prefix used when storing a babylon texture object reference on a Spectre texture object\r\n */\r\n public static BabylonTextureKeyPrefix = \"__babylonTexture_\";\r\n\r\n /**\r\n * Controls anisotropic filtering for deserialized textures.\r\n */\r\n public static MaxAnisotropy = 4;\r\n\r\n /**\r\n * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.\r\n * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.\r\n * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.\r\n * @param scene A Babylon Scene instance\r\n * @param textureCube A Spectre TextureCube object\r\n * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)\r\n * @param environment Specifies that the texture will be used as an environment\r\n * @param singleLod Specifies that the texture will be a singleLod (for environment)\r\n * @returns Babylon cube texture\r\n */\r\n public static GetBabylonCubeTexture(scene: Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment = false, singleLod = false): CubeTexture {\r\n if (!textureCube) {\r\n throw new Error(\"no texture cube provided\");\r\n }\r\n\r\n let parameters: SamplingParameters;\r\n if (environment) {\r\n parameters = singleLod ? TextureUtils._EnvironmentSingleMipSampling : TextureUtils._EnvironmentSampling;\r\n } else {\r\n parameters = {\r\n magFilter: TextureMagFilter.NEAREST,\r\n minFilter: TextureMinFilter.NEAREST,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n };\r\n }\r\n\r\n const key = TextureUtils.BabylonTextureKeyPrefix + parameters.magFilter + \"\" + parameters.minFilter + \"\" + parameters.wrapS + \"\" + parameters.wrapT;\r\n\r\n let babylonTexture: CubeTexture = (<any>textureCube)[key];\r\n\r\n if (!babylonTexture) {\r\n //initialize babylon texture\r\n babylonTexture = new CubeTexture(\"\", scene);\r\n if (environment) {\r\n babylonTexture.lodGenerationOffset = TextureUtils.EnvironmentLODOffset;\r\n babylonTexture.lodGenerationScale = TextureUtils.EnvironmentLODScale;\r\n }\r\n\r\n babylonTexture.gammaSpace = false;\r\n\r\n const internalTexture = new InternalTexture(scene.getEngine(), InternalTextureSource.CubeRaw);\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n //babylon properties\r\n internalTexture.isCube = true;\r\n internalTexture.generateMipMaps = false;\r\n\r\n babylonTexture._texture = internalTexture;\r\n\r\n TextureUtils.ApplySamplingParameters(babylonTexture, parameters);\r\n\r\n const maxMipLevel = automaticMipmaps ? 0 : textureCube.source.length - 1;\r\n let texturesUploaded = 0;\r\n\r\n const textureComplete = function () {\r\n return texturesUploaded === (maxMipLevel + 1) * 6;\r\n };\r\n\r\n const uploadFace = function (i: number, level: number, face: TextureSource) {\r\n if (!glTexture) {\r\n return;\r\n }\r\n\r\n if (i === 0 && level === 0) {\r\n internalTexture.width = face.width;\r\n internalTexture.height = face.height;\r\n }\r\n\r\n const gl = (<any>scene.getEngine())._gl;\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, glTexture);\r\n (scene.getEngine() as Engine)._unpackFlipY(false);\r\n if (face instanceof HTMLElement || face instanceof ImageData) {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, textureCube.internalFormat, textureCube.internalFormat, textureCube.type, <any>face);\r\n } else {\r\n const textureData = <TextureData>face;\r\n gl.texImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + i,\r\n level,\r\n textureCube.internalFormat,\r\n textureData.width,\r\n textureData.height,\r\n 0,\r\n textureData.format,\r\n textureCube.type,\r\n textureData.data\r\n );\r\n }\r\n\r\n texturesUploaded++;\r\n\r\n if (textureComplete()) {\r\n //generate mipmaps\r\n if (automaticMipmaps) {\r\n const w = face.width;\r\n const h = face.height;\r\n const isPot = (w !== 0 && w & (w - 1)) === 0 && (h !== 0 && h & (h - 1)) === 0;\r\n if (isPot) {\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n }\r\n }\r\n\r\n // Upload Separate lods in case there is no support for texture lod.\r\n if (environment && !scene.getEngine().getCaps().textureLOD && !singleLod) {\r\n const mipSlices = 3;\r\n for (let i = 0; i < mipSlices; i++) {\r\n const lodKey = TextureUtils.BabylonTextureKeyPrefix + \"lod\" + i;\r\n let lod: CubeTexture = (<any>textureCube)[lodKey];\r\n\r\n //initialize lod texture if it doesn't already exist\r\n if (lod == null && textureCube.Width) {\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const smoothness = i / (mipSlices - 1);\r\n const roughness = 1 - smoothness;\r\n const kMinimumVariance = 0.0005;\r\n const alphaG = roughness * roughness + kMinimumVariance;\r\n const microsurfaceAverageSlopeTexels = alphaG * textureCube.Width;\r\n\r\n const environmentSpecularLOD = TextureUtils.EnvironmentLODScale * Math.log2(microsurfaceAverageSlopeTexels) + TextureUtils.EnvironmentLODOffset;\r\n\r\n const maxLODIndex = textureCube.source.length - 1;\r\n const mipmapIndex = Math.min(Math.max(Math.round(environmentSpecularLOD), 0), maxLODIndex);\r\n\r\n lod = TextureUtils.GetBabylonCubeTexture(\r\n scene,\r\n new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, [textureCube.source[mipmapIndex]]),\r\n false,\r\n true,\r\n true\r\n );\r\n\r\n if (i === 0) {\r\n internalTexture._lodTextureLow = lod;\r\n } else if (i === 1) {\r\n internalTexture._lodTextureMid = lod;\r\n } else {\r\n internalTexture._lodTextureHigh = lod;\r\n }\r\n\r\n (<any>textureCube)[lodKey] = lod;\r\n }\r\n }\r\n }\r\n\r\n internalTexture.isReady = true;\r\n }\r\n\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);\r\n scene.getEngine().resetTextureCache();\r\n };\r\n\r\n for (let i = 0; i <= maxMipLevel; i++) {\r\n const faces = textureCube.source[i];\r\n for (let j = 0; j < faces.length; j++) {\r\n const face = faces[j];\r\n if (face instanceof HTMLImageElement && !face.complete) {\r\n face.addEventListener(\r\n \"load\",\r\n () => {\r\n uploadFace(j, i, face);\r\n },\r\n false\r\n );\r\n } else {\r\n uploadFace(j, i, face);\r\n }\r\n }\r\n }\r\n\r\n scene.getEngine().resetTextureCache();\r\n\r\n babylonTexture.isReady = () => {\r\n return textureComplete();\r\n };\r\n\r\n (<any>textureCube)[key] = babylonTexture;\r\n }\r\n\r\n return babylonTexture;\r\n }\r\n\r\n /**\r\n * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields\r\n * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)\r\n * @param parameters Spectre SamplingParameters to apply\r\n */\r\n public static ApplySamplingParameters(babylonTexture: BaseTexture, parameters: SamplingParameters) {\r\n const scene = babylonTexture.getScene();\r\n if (!scene) {\r\n return;\r\n }\r\n const gl = (<any>scene.getEngine())._gl;\r\n\r\n const target = babylonTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\r\n\r\n const internalTexture = babylonTexture._texture;\r\n if (!internalTexture) {\r\n return;\r\n }\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n gl.bindTexture(target, glTexture);\r\n\r\n if (parameters.magFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, parameters.magFilter);\r\n }\r\n if (parameters.minFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, parameters.minFilter);\r\n }\r\n if (parameters.wrapS != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, parameters.wrapS);\r\n }\r\n if (parameters.wrapT != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, parameters.wrapT);\r\n }\r\n\r\n //set babylon wrap modes from sampling parameter\r\n switch (parameters.wrapS) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapU = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n switch (parameters.wrapT) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapV = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n if (parameters.maxAnisotropy != null && parameters.maxAnisotropy > 1) {\r\n const anisotropicExt = gl.getExtension(\"EXT_texture_filter_anisotropic\");\r\n if (anisotropicExt) {\r\n const maxAnisotropicSamples = gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\r\n const maxAnisotropy = Math.min(parameters.maxAnisotropy, maxAnisotropicSamples);\r\n gl.texParameterf(target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);\r\n babylonTexture.anisotropicFilteringLevel = maxAnisotropy;\r\n }\r\n }\r\n\r\n gl.bindTexture(target, null);\r\n scene.getEngine().resetTextureCache();\r\n }\r\n\r\n private static _EnvironmentSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR_MIPMAP_LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n private static _EnvironmentSingleMipSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n //from \"/Internal/Lighting.EnvironmentFilterScale\" in Engine/*/Configuration.cpp\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only).\r\n */\r\n public static EnvironmentLODScale = 0.8;\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only)..\r\n */\r\n public static EnvironmentLODOffset = 1.0;\r\n}\r\n"]}
1
+ {"version":3,"file":"texture.js","sourceRoot":"","sources":["../../../../tools/viewer/src/labs/texture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,E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CAAC;IAEa,0CAA6B,GAAuB;QAC/D,SAAS,oCAAyB;QAClC,SAAS,oCAAyB;QAClC,KAAK,2CAA+B;QACpC,KAAK,2CAA+B;QACpC,aAAa,EAAE,CAAC;KACnB,CAAC;IAEF,gFAAgF;IAChF;;OAEG;IACW,gCAAmB,GAAG,GAAG,CAAC;IACxC;;OAEG;IACW,iCAAoB,GAAG,GAAG,CAAC;IAC7C,mBAAC;CAAA,AAtSD,IAsSC;SAtSY,YAAY","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport { CubeTexture } from \"core/Materials/Textures/cubeTexture\";\r\nimport { InternalTexture, InternalTextureSource } from \"core/Materials/Textures/internalTexture\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\n/**\r\n * WebGL Pixel Formats\r\n */\r\nexport const enum PixelFormat {\r\n DEPTH_COMPONENT = 0x1902,\r\n ALPHA = 0x1906,\r\n RGB = 0x1907,\r\n RGBA = 0x1908,\r\n LUMINANCE = 0x1909,\r\n LUMINANCE_ALPHA = 0x190a,\r\n}\r\n\r\n/**\r\n * WebGL Pixel Types\r\n */\r\nexport const enum PixelType {\r\n UNSIGNED_BYTE = 0x1401,\r\n UNSIGNED_SHORT_4_4_4_4 = 0x8033,\r\n UNSIGNED_SHORT_5_5_5_1 = 0x8034,\r\n UNSIGNED_SHORT_5_6_5 = 0x8363,\r\n}\r\n\r\n/**\r\n * WebGL Texture Magnification Filter\r\n */\r\nexport const enum TextureMagFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n}\r\n\r\n/**\r\n * WebGL Texture Minification Filter\r\n */\r\nexport const enum TextureMinFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n NEAREST_MIPMAP_NEAREST = 0x2700,\r\n LINEAR_MIPMAP_NEAREST = 0x2701,\r\n NEAREST_MIPMAP_LINEAR = 0x2702,\r\n LINEAR_MIPMAP_LINEAR = 0x2703,\r\n}\r\n\r\n/**\r\n * WebGL Texture Wrap Modes\r\n */\r\nexport const enum TextureWrapMode {\r\n REPEAT = 0x2901,\r\n CLAMP_TO_EDGE = 0x812f,\r\n MIRRORED_REPEAT = 0x8370,\r\n}\r\n\r\n/**\r\n * Raw texture data and descriptor sufficient for WebGL texture upload\r\n */\r\nexport interface TextureData {\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n /**\r\n * Height of image\r\n */\r\n height: number;\r\n /**\r\n * Format of pixels in data\r\n */\r\n format: PixelFormat;\r\n /**\r\n * Row byte alignment of pixels in data\r\n */\r\n alignment: number;\r\n /**\r\n * Pixel data\r\n */\r\n data: ArrayBufferView;\r\n}\r\n\r\n/**\r\n * Wraps sampling parameters for a WebGL texture\r\n */\r\nexport interface SamplingParameters {\r\n /**\r\n * Magnification mode when upsampling from a WebGL texture\r\n */\r\n magFilter?: TextureMagFilter;\r\n /**\r\n * Minification mode when upsampling from a WebGL texture\r\n */\r\n minFilter?: TextureMinFilter;\r\n /**\r\n * X axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapS?: TextureWrapMode;\r\n /**\r\n * Y axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapT?: TextureWrapMode;\r\n /**\r\n * Anisotropic filtering samples\r\n */\r\n maxAnisotropy?: number;\r\n}\r\n\r\n/**\r\n * Represents a valid WebGL texture source for use in texImage2D\r\n */\r\nexport type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;\r\n\r\n/**\r\n * A generic set of texture mipmaps (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps<T> = Array<T>;\r\n\r\n/**\r\n * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]\r\n */\r\nexport type Faces<T> = Array<T>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps2D = Mipmaps<TextureSource>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type MipmapsCube = Mipmaps<Faces<TextureSource>>;\r\n\r\n/**\r\n * A minimal WebGL cubemap descriptor\r\n */\r\nexport class TextureCube {\r\n /**\r\n * Returns the width of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Width(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].width : 0;\r\n }\r\n\r\n /**\r\n * Returns the height of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Height(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].height : 0;\r\n }\r\n\r\n /**\r\n * constructor\r\n * @param internalFormat WebGL pixel format for the texture on the GPU\r\n * @param type WebGL pixel type of the supplied data and texture on the GPU\r\n * @param source An array containing mipmap levels of faces, where each mipmap level is an array of faces and each face is a TextureSource object\r\n */\r\n constructor(\r\n public internalFormat: PixelFormat,\r\n public type: PixelType,\r\n public source: MipmapsCube = []\r\n ) {}\r\n}\r\n\r\n/**\r\n * A static class providing methods to aid working with Bablyon textures.\r\n */\r\nexport class TextureUtils {\r\n /**\r\n * A prefix used when storing a babylon texture object reference on a Spectre texture object\r\n */\r\n public static BabylonTextureKeyPrefix = \"__babylonTexture_\";\r\n\r\n /**\r\n * Controls anisotropic filtering for deserialized textures.\r\n */\r\n public static MaxAnisotropy = 4;\r\n\r\n /**\r\n * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.\r\n * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.\r\n * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.\r\n * @param scene A Babylon Scene instance\r\n * @param textureCube A Spectre TextureCube object\r\n * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)\r\n * @param environment Specifies that the texture will be used as an environment\r\n * @param singleLod Specifies that the texture will be a singleLod (for environment)\r\n * @returns Babylon cube texture\r\n */\r\n public static GetBabylonCubeTexture(scene: Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment = false, singleLod = false): CubeTexture {\r\n if (!textureCube) {\r\n throw new Error(\"no texture cube provided\");\r\n }\r\n\r\n let parameters: SamplingParameters;\r\n if (environment) {\r\n parameters = singleLod ? TextureUtils._EnvironmentSingleMipSampling : TextureUtils._EnvironmentSampling;\r\n } else {\r\n parameters = {\r\n magFilter: TextureMagFilter.NEAREST,\r\n minFilter: TextureMinFilter.NEAREST,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n };\r\n }\r\n\r\n const key = TextureUtils.BabylonTextureKeyPrefix + parameters.magFilter + \"\" + parameters.minFilter + \"\" + parameters.wrapS + \"\" + parameters.wrapT;\r\n\r\n let babylonTexture: CubeTexture = (<any>textureCube)[key];\r\n\r\n if (!babylonTexture) {\r\n //initialize babylon texture\r\n babylonTexture = new CubeTexture(\"\", scene);\r\n if (environment) {\r\n babylonTexture.lodGenerationOffset = TextureUtils.EnvironmentLODOffset;\r\n babylonTexture.lodGenerationScale = TextureUtils.EnvironmentLODScale;\r\n }\r\n\r\n babylonTexture.gammaSpace = false;\r\n\r\n const internalTexture = new InternalTexture(scene.getEngine(), InternalTextureSource.CubeRaw);\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n //babylon properties\r\n internalTexture.isCube = true;\r\n internalTexture.generateMipMaps = false;\r\n\r\n babylonTexture._texture = internalTexture;\r\n\r\n TextureUtils.ApplySamplingParameters(babylonTexture, parameters);\r\n\r\n const maxMipLevel = automaticMipmaps ? 0 : textureCube.source.length - 1;\r\n let texturesUploaded = 0;\r\n\r\n const textureComplete = function () {\r\n return texturesUploaded === (maxMipLevel + 1) * 6;\r\n };\r\n\r\n const uploadFace = function (i: number, level: number, face: TextureSource) {\r\n if (!glTexture) {\r\n return;\r\n }\r\n\r\n if (i === 0 && level === 0) {\r\n internalTexture.width = face.width;\r\n internalTexture.height = face.height;\r\n }\r\n\r\n const gl = (<any>scene.getEngine())._gl;\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, glTexture);\r\n (scene.getEngine() as Engine)._unpackFlipY(false);\r\n if (face instanceof HTMLElement || face instanceof ImageData) {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, textureCube.internalFormat, textureCube.internalFormat, textureCube.type, <any>face);\r\n } else {\r\n const textureData = <TextureData>face;\r\n gl.texImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + i,\r\n level,\r\n textureCube.internalFormat,\r\n textureData.width,\r\n textureData.height,\r\n 0,\r\n textureData.format,\r\n textureCube.type,\r\n textureData.data\r\n );\r\n }\r\n\r\n texturesUploaded++;\r\n\r\n if (textureComplete()) {\r\n //generate mipmaps\r\n if (automaticMipmaps) {\r\n const w = face.width;\r\n const h = face.height;\r\n const isPot = (w !== 0 && w & (w - 1)) === 0 && (h !== 0 && h & (h - 1)) === 0;\r\n if (isPot) {\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n }\r\n }\r\n\r\n // Upload Separate lods in case there is no support for texture lod.\r\n if (environment && !scene.getEngine().getCaps().textureLOD && !singleLod) {\r\n const mipSlices = 3;\r\n for (let i = 0; i < mipSlices; i++) {\r\n const lodKey = TextureUtils.BabylonTextureKeyPrefix + \"lod\" + i;\r\n let lod: CubeTexture = (<any>textureCube)[lodKey];\r\n\r\n //initialize lod texture if it doesn't already exist\r\n if (lod == null && textureCube.Width) {\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const smoothness = i / (mipSlices - 1);\r\n const roughness = 1 - smoothness;\r\n const kMinimumVariance = 0.0005;\r\n const alphaG = roughness * roughness + kMinimumVariance;\r\n const microsurfaceAverageSlopeTexels = alphaG * textureCube.Width;\r\n\r\n const environmentSpecularLOD = TextureUtils.EnvironmentLODScale * Math.log2(microsurfaceAverageSlopeTexels) + TextureUtils.EnvironmentLODOffset;\r\n\r\n const maxLODIndex = textureCube.source.length - 1;\r\n const mipmapIndex = Math.min(Math.max(Math.round(environmentSpecularLOD), 0), maxLODIndex);\r\n\r\n lod = TextureUtils.GetBabylonCubeTexture(\r\n scene,\r\n new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, [textureCube.source[mipmapIndex]]),\r\n false,\r\n true,\r\n true\r\n );\r\n\r\n if (i === 0) {\r\n internalTexture._lodTextureLow = lod;\r\n } else if (i === 1) {\r\n internalTexture._lodTextureMid = lod;\r\n } else {\r\n internalTexture._lodTextureHigh = lod;\r\n }\r\n\r\n (<any>textureCube)[lodKey] = lod;\r\n }\r\n }\r\n }\r\n\r\n internalTexture.isReady = true;\r\n }\r\n\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);\r\n scene.getEngine().resetTextureCache();\r\n };\r\n\r\n for (let i = 0; i <= maxMipLevel; i++) {\r\n const faces = textureCube.source[i];\r\n for (let j = 0; j < faces.length; j++) {\r\n const face = faces[j];\r\n if (face instanceof HTMLImageElement && !face.complete) {\r\n face.addEventListener(\r\n \"load\",\r\n () => {\r\n uploadFace(j, i, face);\r\n },\r\n false\r\n );\r\n } else {\r\n uploadFace(j, i, face);\r\n }\r\n }\r\n }\r\n\r\n scene.getEngine().resetTextureCache();\r\n\r\n babylonTexture.isReady = () => {\r\n return textureComplete();\r\n };\r\n\r\n (<any>textureCube)[key] = babylonTexture;\r\n }\r\n\r\n return babylonTexture;\r\n }\r\n\r\n /**\r\n * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields\r\n * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)\r\n * @param parameters Spectre SamplingParameters to apply\r\n */\r\n public static ApplySamplingParameters(babylonTexture: BaseTexture, parameters: SamplingParameters) {\r\n const scene = babylonTexture.getScene();\r\n if (!scene) {\r\n return;\r\n }\r\n const gl = (<any>scene.getEngine())._gl;\r\n\r\n const target = babylonTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\r\n\r\n const internalTexture = babylonTexture._texture;\r\n if (!internalTexture) {\r\n return;\r\n }\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n gl.bindTexture(target, glTexture);\r\n\r\n if (parameters.magFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, parameters.magFilter);\r\n }\r\n if (parameters.minFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, parameters.minFilter);\r\n }\r\n if (parameters.wrapS != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, parameters.wrapS);\r\n }\r\n if (parameters.wrapT != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, parameters.wrapT);\r\n }\r\n\r\n //set babylon wrap modes from sampling parameter\r\n switch (parameters.wrapS) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapU = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n switch (parameters.wrapT) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapV = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n if (parameters.maxAnisotropy != null && parameters.maxAnisotropy > 1) {\r\n const anisotropicExt = gl.getExtension(\"EXT_texture_filter_anisotropic\");\r\n if (anisotropicExt) {\r\n const maxAnisotropicSamples = gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\r\n const maxAnisotropy = Math.min(parameters.maxAnisotropy, maxAnisotropicSamples);\r\n gl.texParameterf(target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);\r\n babylonTexture.anisotropicFilteringLevel = maxAnisotropy;\r\n }\r\n }\r\n\r\n gl.bindTexture(target, null);\r\n scene.getEngine().resetTextureCache();\r\n }\r\n\r\n private static _EnvironmentSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR_MIPMAP_LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n private static _EnvironmentSingleMipSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n //from \"/Internal/Lighting.EnvironmentFilterScale\" in Engine/*/Configuration.cpp\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only).\r\n */\r\n public static EnvironmentLODScale = 0.8;\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only)..\r\n */\r\n public static EnvironmentLODOffset = 1.0;\r\n}\r\n"]}