configuration.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import { ICameraConfiguration, IDefaultRenderingPipelineConfiguration, IGroundConfiguration, ILightConfiguration, IModelConfiguration, IObserversConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, ISkyboxConfiguration, ITemplateConfiguration, IVRConfiguration } from './interfaces';
  2. import { IEnvironmentMapConfiguration } from './interfaces/environmentMapConfiguration';
  3. import { EngineOptions } from 'babylonjs/Engines/thinEngine';
  4. export function getConfigurationKey(key: string, configObject: any) {
  5. let splits = key.split('.');
  6. if (splits.length === 0 || !configObject) { return; }
  7. else if (splits.length === 1) {
  8. if (configObject[key] !== undefined) {
  9. return configObject[key];
  10. }
  11. } else {
  12. let firstKey = splits.shift();
  13. return getConfigurationKey(splits.join("."), configObject[firstKey!]);
  14. }
  15. }
  16. export interface ViewerConfiguration {
  17. // configuration version
  18. version?: string;
  19. extends?: string; // is this configuration extending an existing configuration?
  20. pageUrl?: string; // will be used for sharing and other fun stuff. This is the page showing the model (not the model's url!)
  21. configuration?: string | {
  22. url?: string;
  23. payload?: any;
  24. mapper?: string; // json (default), html, yaml, xml, etc'. if not provided, file extension will be used.
  25. };
  26. // names of functions in the window context.
  27. observers?: IObserversConfiguration;
  28. canvasElement?: string; // if there is a need to override the standard implementation - ID of HTMLCanvasElement
  29. model?: IModelConfiguration | string;
  30. scene?: ISceneConfiguration;
  31. optimizer?: ISceneOptimizerConfiguration | boolean;
  32. // at the moment, support only a single camera.
  33. camera?: ICameraConfiguration;
  34. skybox?: boolean | ISkyboxConfiguration;
  35. ground?: boolean | IGroundConfiguration;
  36. lights?: {
  37. //globalRotation: number,
  38. [name: string]: number | boolean | ILightConfiguration
  39. };
  40. // engine configuration. optional!
  41. engine?: {
  42. renderInBackground?: boolean;
  43. antialiasing?: boolean;
  44. disableResize?: boolean;
  45. engineOptions?: EngineOptions;
  46. adaptiveQuality?: boolean;
  47. hdEnabled?: boolean;
  48. };
  49. //templateStructure?: ITemplateStructure,
  50. templates?: {
  51. main: ITemplateConfiguration,
  52. [key: string]: ITemplateConfiguration
  53. };
  54. customShaders?: {
  55. shaders?: {
  56. [key: string]: string;
  57. };
  58. includes?: {
  59. [key: string]: string;
  60. }
  61. };
  62. loaderPlugins?: {
  63. extendedMaterial?: boolean;
  64. msftLod?: boolean;
  65. telemetry?: boolean;
  66. minecraft?: boolean;
  67. [propName: string]: boolean | undefined;
  68. };
  69. environmentMap?: IEnvironmentMapConfiguration;
  70. vr?: IVRConfiguration;
  71. // features that are being tested.
  72. // those features' syntax will change and move out!
  73. // Don't use in production (or be ready to make the changes :) )
  74. lab?: {
  75. flashlight?: boolean | {
  76. exponent?: number;
  77. angle?: number;
  78. intensity?: number;
  79. diffuse?: { r: number, g: number, b: number };
  80. specular?: { r: number, g: number, b: number };
  81. }
  82. hideLoadingDelay?: number;
  83. /** Deprecated */
  84. assetsRootURL?: string;
  85. environmentMainColor?: { r: number, g: number, b: number };
  86. /** Deprecated */
  87. environmentMap?: {
  88. /**
  89. * Environment map texture path in relative to the asset folder.
  90. */
  91. texture: string;
  92. /**
  93. * Default rotation to apply to the environment map.
  94. */
  95. rotationY: number;
  96. /**
  97. * Tint level of the main color on the environment map.
  98. */
  99. tintLevel: number;
  100. }
  101. defaultRenderingPipelines?: boolean | IDefaultRenderingPipelineConfiguration;
  102. globalLightRotation?: number;
  103. };
  104. }