configuration.ts 3.9 KB

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