configuration.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. import { ITemplateConfiguration } from './../templateManager';
  2. import { EngineOptions } from 'babylonjs';
  3. export interface ViewerConfiguration {
  4. // configuration version
  5. version?: string;
  6. extends?: string; // is this configuration extending an existing configuration?
  7. pageUrl?: string; // will be used for sharing and other fun stuff. This is the page showing the model (not the model's url!)
  8. configuration?: string | {
  9. url?: string;
  10. payload?: any;
  11. mapper?: string; // json (default), html, yaml, xml, etc'. if not provided, file extension will be used.
  12. };
  13. // names of functions in the window context.
  14. observers?: IObserversConfiguration;
  15. canvasElement?: string; // if there is a need to override the standard implementation - ID of HTMLCanvasElement
  16. model?: IModelConfiguration | string;
  17. scene?: ISceneConfiguration;
  18. optimizer?: ISceneOptimizerConfiguration | boolean;
  19. // at the moment, support only a single camera.
  20. camera?: ICameraConfiguration,
  21. skybox?: boolean | ISkyboxConfiguration;
  22. ground?: boolean | IGroundConfiguration;
  23. lights?: { [name: string]: boolean | ILightConfiguration },
  24. // engine configuration. optional!
  25. engine?: {
  26. antialiasing?: boolean;
  27. disableResize?: boolean;
  28. engineOptions?: EngineOptions;
  29. adaptiveQuality?: boolean;
  30. },
  31. //templateStructure?: ITemplateStructure,
  32. templates?: {
  33. main: ITemplateConfiguration,
  34. [key: string]: ITemplateConfiguration
  35. };
  36. customShaders?: {
  37. shaders?: {
  38. [key: string]: string;
  39. };
  40. includes?: {
  41. [key: string]: string;
  42. }
  43. }
  44. // features that are being tested.
  45. // those features' syntax will change and move out!
  46. // Don't use in production (or be ready to make the changes :) )
  47. lab?: {
  48. flashlight?: boolean | {
  49. exponent?: number;
  50. angle?: number;
  51. intensity?: number;
  52. diffuse?: { r: number, g: number, b: number };
  53. specular?: { r: number, g: number, b: number };
  54. }
  55. hideLoadingDelay?: number;
  56. environmentAssetsRootURL?: string;
  57. environmentMap?: {
  58. /**
  59. * Environment map texture path in relative to the asset folder.
  60. */
  61. texture: string;
  62. /**
  63. * Default rotation to apply to the environment map.
  64. */
  65. rotationY: number;
  66. /**
  67. * Tint level of the main color on the environment map.
  68. */
  69. tintLevel: number;
  70. }
  71. }
  72. }
  73. export interface IModelConfiguration {
  74. url?: string;
  75. root?: string; //optional
  76. loader?: string; // obj, gltf?
  77. position?: { x: number, y: number, z: number };
  78. rotation?: { x: number, y: number, z: number, w?: number };
  79. scaling?: { x: number, y: number, z: number };
  80. parentObjectIndex?: number; // the index of the parent object of the model in the loaded meshes array.
  81. castShadow?: boolean;
  82. receiveShadows?: boolean;
  83. normalize?: boolean | {
  84. center?: boolean;
  85. unitSize?: boolean;
  86. parentIndex?: number;
  87. }; // should the model be scaled to unit-size
  88. title?: string;
  89. subtitle?: string;
  90. thumbnail?: string; // URL or data-url
  91. animation?: {
  92. autoStart?: boolean | string;
  93. playOnce?: boolean;
  94. }
  95. material?: {
  96. directEnabled?: boolean;
  97. directIntensity?: number;
  98. emissiveIntensity?: number;
  99. environmentIntensity?: number;
  100. [propName: string]: any;
  101. }
  102. /**
  103. * Rotation offset axis definition
  104. */
  105. rotationOffsetAxis?: {
  106. x: number;
  107. y: number;
  108. z: number;
  109. };
  110. /**
  111. * the offset angle
  112. */
  113. rotationOffsetAngle?: number;
  114. // [propName: string]: any; // further configuration, like title and creator
  115. }
  116. export interface ISkyboxConfiguration {
  117. cubeTexture?: {
  118. noMipMap?: boolean;
  119. gammaSpace?: boolean;
  120. url?: string | Array<string>;
  121. };
  122. color?: { r: number, g: number, b: number };
  123. pbr?: boolean; // deprecated
  124. scale?: number;
  125. blur?: number; // deprecated
  126. material?: {
  127. imageProcessingConfiguration?: IImageProcessingConfiguration;
  128. [propName: string]: any;
  129. };
  130. infiniteDistance?: boolean;
  131. }
  132. export interface IGroundConfiguration {
  133. size?: number;
  134. receiveShadows?: boolean;
  135. shadowLevel?: number;
  136. shadowOnly?: boolean; // deprecated
  137. mirror?: boolean | {
  138. sizeRatio?: number;
  139. blurKernel?: number;
  140. amount?: number;
  141. fresnelWeight?: number;
  142. fallOffDistance?: number;
  143. textureType?: number;
  144. };
  145. texture?: string;
  146. color?: { r: number, g: number, b: number };
  147. opacity?: number;
  148. material?: { // deprecated!
  149. [propName: string]: any;
  150. };
  151. }
  152. export interface ISceneConfiguration {
  153. debug?: boolean;
  154. clearColor?: { r: number, g: number, b: number, a: number };
  155. mainColor?: { r: number, g: number, b: number };
  156. imageProcessingConfiguration?: IImageProcessingConfiguration;
  157. environmentTexture?: string;
  158. colorGrading?: IColorGradingConfiguration;
  159. environmentRotationY?: number;
  160. }
  161. /**
  162. * The Color Grading Configuration groups the different settings used to define the color grading used in the viewer.
  163. */
  164. export interface IColorGradingConfiguration {
  165. /**
  166. * Transform data string, encoded as determined by transformDataFormat.
  167. */
  168. transformData: string;
  169. /**
  170. * The encoding format of TransformData (currently only raw-base16 is supported).
  171. */
  172. transformDataFormat: string;
  173. /**
  174. * The weight of the transform
  175. */
  176. transformWeight: number;
  177. /**
  178. * Color curve colorFilterHueGlobal value
  179. */
  180. colorFilterHueGlobal: number;
  181. /**
  182. * Color curve colorFilterHueShadows value
  183. */
  184. colorFilterHueShadows: number;
  185. /**
  186. * Color curve colorFilterHueMidtones value
  187. */
  188. colorFilterHueMidtones: number;
  189. /**
  190. * Color curve colorFilterHueHighlights value
  191. */
  192. colorFilterHueHighlights: number;
  193. /**
  194. * Color curve colorFilterDensityGlobal value
  195. */
  196. colorFilterDensityGlobal: number;
  197. /**
  198. * Color curve colorFilterDensityShadows value
  199. */
  200. colorFilterDensityShadows: number;
  201. /**
  202. * Color curve colorFilterDensityMidtones value
  203. */
  204. colorFilterDensityMidtones: number;
  205. /**
  206. * Color curve colorFilterDensityHighlights value
  207. */
  208. colorFilterDensityHighlights: number;
  209. /**
  210. * Color curve saturationGlobal value
  211. */
  212. saturationGlobal: number;
  213. /**
  214. * Color curve saturationShadows value
  215. */
  216. saturationShadows: number;
  217. /**
  218. * Color curve saturationMidtones value
  219. */
  220. saturationMidtones: number;
  221. /**
  222. * Color curve saturationHighlights value
  223. */
  224. saturationHighlights: number;
  225. /**
  226. * Color curve exposureGlobal value
  227. */
  228. exposureGlobal: number;
  229. /**
  230. * Color curve exposureShadows value
  231. */
  232. exposureShadows: number;
  233. /**
  234. * Color curve exposureMidtones value
  235. */
  236. exposureMidtones: number;
  237. /**
  238. * Color curve exposureHighlights value
  239. */
  240. exposureHighlights: number;
  241. }
  242. export interface ISceneOptimizerConfiguration {
  243. targetFrameRate?: number;
  244. trackerDuration?: number;
  245. autoGeneratePriorities?: boolean;
  246. improvementMode?: boolean;
  247. degradation?: string; // low, moderate, high
  248. types?: {
  249. texture?: ISceneOptimizerParameters;
  250. hardwareScaling?: ISceneOptimizerParameters;
  251. shadow?: ISceneOptimizerParameters;
  252. postProcess?: ISceneOptimizerParameters;
  253. lensFlare?: ISceneOptimizerParameters;
  254. particles?: ISceneOptimizerParameters;
  255. renderTarget?: ISceneOptimizerParameters;
  256. mergeMeshes?: ISceneOptimizerParameters;
  257. }
  258. }
  259. export interface IObserversConfiguration {
  260. onEngineInit?: string;
  261. onSceneInit?: string;
  262. onModelLoaded?: string;
  263. }
  264. export interface ICameraConfiguration {
  265. position?: { x: number, y: number, z: number };
  266. rotation?: { x: number, y: number, z: number, w: number };
  267. fov?: number;
  268. fovMode?: number;
  269. minZ?: number;
  270. maxZ?: number;
  271. inertia?: number;
  272. behaviors?: {
  273. [name: string]: number | {
  274. type: number;
  275. [propName: string]: any;
  276. };
  277. };
  278. disableCameraControl?: boolean;
  279. disableCtrlForPanning?: boolean;
  280. disableAutoFocus?: boolean;
  281. [propName: string]: any;
  282. }
  283. export interface ILightConfiguration {
  284. type: number;
  285. name?: string;
  286. disabled?: boolean;
  287. position?: { x: number, y: number, z: number };
  288. target?: { x: number, y: number, z: number };
  289. direction?: { x: number, y: number, z: number };
  290. diffuse?: { r: number, g: number, b: number };
  291. specular?: { r: number, g: number, b: number };
  292. intensity?: number;
  293. intensityMode?: number;
  294. radius?: number;
  295. shadownEnabled?: boolean; // only on specific lights!
  296. shadowConfig?: {
  297. useBlurExponentialShadowMap?: boolean;
  298. useKernelBlur?: boolean;
  299. blurKernel?: number;
  300. blurScale?: number;
  301. minZ?: number;
  302. maxZ?: number;
  303. frustumSize?: number;
  304. angleScale?: number;
  305. frustumEdgeFalloff?: number;
  306. [propName: string]: any;
  307. };
  308. spotAngle?: number;
  309. shadowFieldOfView?: number;
  310. shadowBufferSize?: number;
  311. shadowFrustumSize?: number;
  312. shadowMinZ?: number;
  313. shadowMaxZ?: number;
  314. [propName: string]: any;
  315. // no behaviors for light at the moment, but allowing configuration for future reference.
  316. behaviors?: {
  317. [name: string]: number | {
  318. type: number;
  319. [propName: string]: any;
  320. };
  321. };
  322. }
  323. export interface ISceneOptimizerParameters {
  324. priority?: number;
  325. maximumSize?: number;
  326. step?: number;
  327. }
  328. export interface IImageProcessingConfiguration {
  329. colorGradingEnabled?: boolean;
  330. colorCurvesEnabled?: boolean;
  331. colorCurves?: {
  332. globalHue?: number;
  333. globalDensity?: number;
  334. globalSaturation?: number;
  335. globalExposure?: number;
  336. highlightsHue?: number;
  337. highlightsDensity?: number;
  338. highlightsSaturation?: number;
  339. highlightsExposure?: number;
  340. midtonesHue?: number;
  341. midtonesDensity?: number;
  342. midtonesSaturation?: number;
  343. midtonesExposure?: number;
  344. shadowsHue?: number;
  345. shadowsDensity?: number;
  346. shadowsSaturation?: number;
  347. shadowsExposure?: number;
  348. };
  349. colorGradingWithGreenDepth?: boolean;
  350. colorGradingBGR?: boolean;
  351. exposure?: number;
  352. toneMappingEnabled?: boolean;
  353. contrast?: number;
  354. vignetteEnabled?: boolean;
  355. vignetteStretch?: number;
  356. vignetteCentreX?: number;
  357. vignetteCentreY?: number;
  358. vignetteWeight?: number;
  359. vignetteColor?: { r: number, g: number, b: number, a?: number };
  360. vignetteCameraFov?: number;
  361. vignetteBlendMode?: number;
  362. vignetteM?: boolean;
  363. applyByPostProcess?: boolean;
  364. isEnabled?: boolean;
  365. }