babylon.viewer.d.ts 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178
  1. /// <reference path="./babylon.module.d.ts"/>
  2. /// <reference path="./babylon.glTF2Interface.d.ts"/>
  3. /// <reference path="./babylonjs.loaders.module.d.ts"/>
  4. // Generated by dts-bundle v0.7.3
  5. // Dependencies for this module:
  6. // ../../../../../Tools/Gulp/babylonjs
  7. // ../../../../../Tools/Gulp/babylonjs-loaders
  8. // ../../../../../Tools/Gulp/babylonjs/Misc/observable
  9. // ../../../../../Tools/Gulp/babylonjs/Engines/engine
  10. // ../../../../../Tools/Gulp/babylonjs/Loading/sceneLoader
  11. // ../../../../../Tools/Gulp/babylonjs/scene
  12. // ../../../../../Tools/Gulp/babylonjs/Meshes/abstractMesh
  13. // ../../../../../Tools/Gulp/babylonjs/Particles/IParticleSystem
  14. // ../../../../../Tools/Gulp/babylonjs/Bones/skeleton
  15. // ../../../../../Tools/Gulp/babylonjs/Animations/animationGroup
  16. // ../../../../../Tools/Gulp/babylonjs/Animations/index
  17. // ../../../../../Tools/Gulp/babylonjs/types
  18. // ../../../../../Tools/Gulp/babylonjs/Materials/material
  19. // ../../../../../Tools/Gulp/babylonjs-gltf2interface
  20. // ../../../../../Tools/Gulp/babylonjs/Maths/math
  21. // ../../../../../Tools/Gulp/babylonjs-loaders/glTF/glTFFileLoader
  22. // ../../../../../Tools/Gulp/babylonjs/Materials/Textures/baseTexture
  23. // ../../../../../Tools/Gulp/babylonjs/Misc/sceneOptimizer
  24. // ../../../../../Tools/Gulp/babylonjs/Cameras/arcRotateCamera
  25. // ../../../../../Tools/Gulp/babylonjs/Lights/light
  26. // ../../../../../Tools/Gulp/babylonjs/Helpers/environmentHelper
  27. // ../../../../../Tools/Gulp/babylonjs/Cameras/VR/vrExperienceHelper
  28. // ../../../../../Tools/Gulp/babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline
  29. // ../../../../../Tools/Gulp/babylonjs/Lights/shadowLight
  30. // ../../../../../Tools/Gulp/babylonjs-loaders/glTF/2.0/glTFLoaderExtension
  31. // ../../../../../Tools/Gulp/babylonjs/PostProcesses/depthOfFieldEffect
  32. declare module BabylonViewer {
  33. /**
  34. * BabylonJS Viewer
  35. *
  36. * An HTML-Based viewer for 3D models, based on BabylonJS and its extensions.
  37. */
  38. let disableInit: boolean;
  39. /**
  40. * Dispose all viewers currently registered
  41. */
  42. function disposeAll(): void;
  43. const Version: string;
  44. export { GLTF2 } from 'babylonjs-loaders';
  45. }
  46. declare module BabylonViewer {
  47. /**
  48. * This is the mapper's interface. Implement this function to create your own mapper and register it at the mapper manager
  49. */
  50. export interface IMapper {
  51. map(rawSource: any): ViewerConfiguration;
  52. }
  53. /**
  54. * The MapperManager manages the different implemented mappers.
  55. * It allows the user to register new mappers as well and use them to parse their own configuration data
  56. */
  57. export class MapperManager {
  58. /**
  59. * The default mapper is the JSON mapper.
  60. */
  61. static DefaultMapper: string;
  62. constructor();
  63. /**
  64. * Get a specific configuration mapper.
  65. *
  66. * @param type the name of the mapper to load
  67. */
  68. getMapper(type: string): IMapper;
  69. /**
  70. * Use this functio to register your own configuration mapper.
  71. * After a mapper is registered, it can be used to parse the specific type fo configuration to the standard ViewerConfiguration.
  72. * @param type the name of the mapper. This will be used to define the configuration type and/or to get the mapper
  73. * @param mapper The implemented mapper
  74. */
  75. registerMapper(type: string, mapper: IMapper): void;
  76. /**
  77. * Dispose the mapper manager and all of its mappers.
  78. */
  79. dispose(): void;
  80. }
  81. /**
  82. * mapperManager is a singleton of the type MapperManager.
  83. * The mapperManager can be disposed directly with calling mapperManager.dispose()
  84. * or indirectly with using BabylonViewer.disposeAll()
  85. */
  86. export let mapperManager: MapperManager;
  87. }
  88. declare module BabylonViewer {
  89. export class ViewerGlobals {
  90. disableInit: boolean;
  91. disableWebGL2Support: boolean;
  92. readonly version: string;
  93. }
  94. export let viewerGlobals: ViewerGlobals;
  95. }
  96. declare module BabylonViewer {
  97. /**
  98. * The viewer manager is the container for all viewers currently registered on this page.
  99. * It is possible to have more than one viewer on a single page.
  100. */
  101. export class ViewerManager {
  102. /**
  103. * A callback that will be triggered when a new viewer was added
  104. */
  105. onViewerAdded: (viewer: AbstractViewer) => void;
  106. /**
  107. * Will notify when a new viewer was added
  108. */
  109. onViewerAddedObservable: BABYLON.Observable<AbstractViewer>;
  110. /**
  111. * Will notify when a viewer was removed (disposed)
  112. */
  113. onViewerRemovedObservable: BABYLON.Observable<string>;
  114. constructor();
  115. /**
  116. * Adding a new viewer to the viewer manager and start tracking it.
  117. * @param viewer the viewer to add
  118. */
  119. addViewer(viewer: AbstractViewer): void;
  120. /**
  121. * remove a viewer from the viewer manager
  122. * @param viewer the viewer to remove
  123. */
  124. removeViewer(viewer: AbstractViewer): void;
  125. /**
  126. * Get a viewer by its baseId (if the container element has an ID, it is the this is. if not, a random id was assigned)
  127. * @param id the id of the HTMl element (or the viewer's, if none provided)
  128. */
  129. getViewerById(id: string): AbstractViewer;
  130. /**
  131. * Get a viewer using a container element
  132. * @param element the HTML element to search viewers associated with
  133. */
  134. getViewerByHTMLElement(element: HTMLElement): AbstractViewer | undefined;
  135. /**
  136. * Get a promise that will fullfil when this viewer was initialized.
  137. * Since viewer initialization and template injection is asynchronous, using the promise will guaranty that
  138. * you will get the viewer after everything was already configured.
  139. * @param id the viewer id to find
  140. */
  141. getViewerPromiseById(id: string): Promise<AbstractViewer>;
  142. /**
  143. * dispose the manager and all of its associated viewers
  144. */
  145. dispose(): void;
  146. }
  147. export let viewerManager: ViewerManager;
  148. }
  149. declare module BabylonViewer {
  150. /**
  151. * The Default viewer is the default implementation of the AbstractViewer.
  152. * It uses the templating system to render a new canvas and controls.
  153. */
  154. export class DefaultViewer extends AbstractViewerWithTemplate {
  155. containerElement: Element;
  156. /**
  157. * The corresponsing template manager of this viewer.
  158. */
  159. templateManager: TemplateManager;
  160. fullscreenElement?: Element;
  161. /**
  162. * Create a new default viewer
  163. * @param containerElement the element in which the templates will be rendered
  164. * @param initialConfiguration the initial configuration. Defaults to extending the default configuration
  165. */
  166. constructor(containerElement: Element, initialConfiguration?: ViewerConfiguration);
  167. registerTemplatePlugin(plugin: IViewerTemplatePlugin): void;
  168. /**
  169. * This will be executed when the templates initialize.
  170. */
  171. protected _onTemplatesLoaded(): Promise<import("babylonjs-viewer/viewer/viewer").AbstractViewer>;
  172. protected _initVR(): void;
  173. /**
  174. * Toggle fullscreen of the entire viewer
  175. */
  176. toggleFullscreen: () => void;
  177. /**
  178. * Preparing the container element to present the viewer
  179. */
  180. protected _prepareContainerElement(): void;
  181. /**
  182. * This function will configure the templates and update them after a model was loaded
  183. * It is mainly responsible to changing the title and subtitle etc'.
  184. * @param model the model to be used to configure the templates by
  185. */
  186. protected _configureTemplate(model?: ViewerModel): void;
  187. /**
  188. * This will load a new model to the default viewer
  189. * overriding the AbstractViewer's loadModel.
  190. * The scene will automatically be cleared of the old models, if exist.
  191. * @param model the configuration object (or URL) to load.
  192. */
  193. loadModel(model?: string | File | IModelConfiguration): Promise<ViewerModel>;
  194. /**
  195. * Show the overlay and the defined sub-screen.
  196. * Mainly used for help and errors
  197. * @param subScreen the name of the subScreen. Those can be defined in the configuration object
  198. */
  199. showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
  200. /**
  201. * Hide the overlay screen.
  202. */
  203. hideOverlayScreen(): Promise<string> | Promise<Template>;
  204. /**
  205. * show the viewer (in case it was hidden)
  206. *
  207. * @param visibilityFunction an optional function to execute in order to show the container
  208. */
  209. show(visibilityFunction?: ((template: Template) => Promise<Template>)): Promise<Template>;
  210. /**
  211. * hide the viewer (in case it is visible)
  212. *
  213. * @param visibilityFunction an optional function to execute in order to hide the container
  214. */
  215. hide(visibilityFunction?: ((template: Template) => Promise<Template>)): Promise<Template>;
  216. /**
  217. * Show the loading screen.
  218. * The loading screen can be configured using the configuration object
  219. */
  220. showLoadingScreen(): Promise<string> | Promise<Template>;
  221. /**
  222. * Hide the loading screen
  223. */
  224. hideLoadingScreen(): Promise<string> | Promise<Template>;
  225. dispose(): void;
  226. protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
  227. }
  228. }
  229. declare module BabylonViewer {
  230. /**
  231. * The AbstractViewer is the center of Babylon's viewer.
  232. * It is the basic implementation of the default viewer and is responsible of loading and showing the model and the templates
  233. */
  234. export abstract class AbstractViewer {
  235. containerElement: Element;
  236. /**
  237. * Babylon BABYLON.Engine corresponding with this viewer
  238. */
  239. engine: BABYLON.Engine;
  240. /**
  241. * The ID of this viewer. it will be generated randomly or use the HTML Element's ID.
  242. */
  243. readonly baseId: string;
  244. /**
  245. * The last loader used to load a model.
  246. * @deprecated
  247. */
  248. lastUsedLoader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync;
  249. /**
  250. * The ModelLoader instance connected with this viewer.
  251. */
  252. modelLoader: ModelLoader;
  253. /**
  254. * A flag that controls whether or not the render loop should be executed
  255. */
  256. runRenderLoop: boolean;
  257. /**
  258. * The scene manager connected with this viewer instance
  259. */
  260. sceneManager: SceneManager;
  261. /**
  262. * Will notify when the scene was initialized
  263. */
  264. readonly onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
  265. /**
  266. * will notify when the engine was initialized
  267. */
  268. readonly onEngineInitObservable: BABYLON.Observable<BABYLON.Engine>;
  269. /**
  270. * Will notify when a new model was added to the scene.
  271. * Note that added does not neccessarily mean loaded!
  272. */
  273. readonly onModelAddedObservable: BABYLON.Observable<ViewerModel>;
  274. /**
  275. * will notify after every model load
  276. */
  277. readonly onModelLoadedObservable: BABYLON.Observable<ViewerModel>;
  278. /**
  279. * will notify when any model notify of progress
  280. */
  281. readonly onModelLoadProgressObservable: BABYLON.Observable<BABYLON.SceneLoaderProgressEvent>;
  282. /**
  283. * will notify when any model load failed.
  284. */
  285. readonly onModelLoadErrorObservable: BABYLON.Observable<{
  286. message: string;
  287. exception: any;
  288. }>;
  289. /**
  290. * Will notify when a model was removed from the scene;
  291. */
  292. readonly onModelRemovedObservable: BABYLON.Observable<ViewerModel>;
  293. /**
  294. * will notify when a new loader was initialized.
  295. * Used mainly to know when a model starts loading.
  296. */
  297. readonly onLoaderInitObservable: BABYLON.Observable<BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync>;
  298. /**
  299. * Observers registered here will be executed when the entire load process has finished.
  300. */
  301. readonly onInitDoneObservable: BABYLON.Observable<AbstractViewer>;
  302. /**
  303. * Functions added to this observable will be executed on each frame rendered.
  304. */
  305. readonly onFrameRenderedObservable: BABYLON.Observable<AbstractViewer>;
  306. /**
  307. * Observers registered here will be executed when VR more is entered.
  308. */
  309. readonly onEnteringVRObservable: BABYLON.Observable<AbstractViewer>;
  310. /**
  311. * Observers registered here will be executed when VR mode is exited.
  312. */
  313. readonly onExitingVRObservable: BABYLON.Observable<AbstractViewer>;
  314. observablesManager: ObservablesManager;
  315. /**
  316. * The canvas associated with this viewer
  317. */
  318. protected _canvas: HTMLCanvasElement;
  319. /**
  320. * The (single) canvas of this viewer
  321. */
  322. readonly canvas: HTMLCanvasElement;
  323. /**
  324. * is this viewer disposed?
  325. */
  326. protected _isDisposed: boolean;
  327. /**
  328. * registered onBeforeRender functions.
  329. * This functions are also registered at the native scene. The reference can be used to unregister them.
  330. */
  331. protected _registeredOnBeforeRenderFunctions: Array<() => void>;
  332. /**
  333. * The configuration loader of this viewer
  334. */
  335. protected _configurationLoader: RenderOnlyConfigurationLoader;
  336. /**
  337. * Is the viewer already initialized. for internal use.
  338. */
  339. protected _isInit: boolean;
  340. protected _configurationContainer: ConfigurationContainer;
  341. readonly configurationContainer: ConfigurationContainer;
  342. protected getConfigurationLoader(): RenderOnlyConfigurationLoader;
  343. constructor(containerElement: Element, initialConfiguration?: ViewerConfiguration);
  344. /**
  345. * get the baseId of this viewer
  346. */
  347. getBaseId(): string;
  348. /**
  349. * Do we have a canvas to render on, and is it a part of the scene
  350. */
  351. isCanvasInDOM(): boolean;
  352. /**
  353. * Set the viewer's background rendering flag.
  354. */
  355. renderInBackground: boolean;
  356. /**
  357. * Get the configuration object. This is a reference only.
  358. * The configuration can ONLY be updated using the updateConfiguration function.
  359. * changing this object will have no direct effect on the scene.
  360. */
  361. readonly configuration: ViewerConfiguration;
  362. /**
  363. * force resizing the engine.
  364. */
  365. forceResize(): void;
  366. protected _hdToggled: boolean;
  367. toggleHD(): void;
  368. protected _vrToggled: boolean;
  369. protected _vrScale: number;
  370. protected _vrInit: boolean;
  371. toggleVR(): void;
  372. protected _initVR(): void;
  373. /**
  374. * The resize function that will be registered with the window object
  375. */
  376. protected _resize: () => void;
  377. protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
  378. /**
  379. * Force a single render loop execution.
  380. */
  381. forceRender(): void;
  382. /**
  383. * render loop that will be executed by the engine
  384. */
  385. protected _render: (force?: boolean) => void;
  386. /**
  387. * Takes a screenshot of the scene and returns it as a base64 encoded png.
  388. * @param callback optional callback that will be triggered when screenshot is done.
  389. * @param width Optional screenshot width (default to 512).
  390. * @param height Optional screenshot height (default to 512).
  391. * @returns a promise with the screenshot data
  392. */
  393. takeScreenshot(callback?: (data: string) => void, width?: number, height?: number): Promise<string>;
  394. /**
  395. * Update the current viewer configuration with new values.
  396. * Only provided information will be updated, old configuration values will be kept.
  397. * If this.configuration was manually changed, you can trigger this function with no parameters,
  398. * and the entire configuration will be updated.
  399. * @param newConfiguration the partial configuration to update or a URL to a JSON holding the updated configuration
  400. *
  401. */
  402. updateConfiguration(newConfiguration?: Partial<ViewerConfiguration> | string): void;
  403. /**
  404. * this is used to register native functions using the configuration object.
  405. * This will configure the observers.
  406. * @param observersConfiguration observers configuration
  407. */
  408. protected _configureObservers(observersConfiguration: IObserversConfiguration): void;
  409. /**
  410. * Dispose the entire viewer including the scene and the engine
  411. */
  412. dispose(): void;
  413. /**
  414. * This will prepare the container element for the viewer
  415. */
  416. protected abstract _prepareContainerElement(): any;
  417. /**
  418. * This function will execute when the HTML templates finished initializing.
  419. * It should initialize the engine and continue execution.
  420. *
  421. * @returns {Promise<AbstractViewer>} The viewer object will be returned after the object was loaded.
  422. */
  423. protected _onTemplatesLoaded(): Promise<AbstractViewer>;
  424. /**
  425. * This will force the creation of an engine and a scene.
  426. * It will also load a model if preconfigured.
  427. * But first - it will load the extendible onTemplateLoaded()!
  428. */
  429. protected _onTemplateLoaded(): Promise<AbstractViewer>;
  430. /**
  431. * Initialize the engine. Retruns a promise in case async calls are needed.
  432. *
  433. * @protected
  434. * @returns {Promise<BABYLON.Engine>}
  435. * @memberof Viewer
  436. */
  437. protected _initEngine(): Promise<BABYLON.Engine>;
  438. /**
  439. * Initialize a model loading. The returned object (a ViewerModel object) will be loaded in the background.
  440. * The difference between this and loadModel is that loadModel will fulfill the promise when the model finished loading.
  441. *
  442. * @param modelConfig model configuration to use when loading the model.
  443. * @param clearScene should the scene be cleared before loading this model
  444. * @returns a ViewerModel object that is not yet fully loaded.
  445. */
  446. initModel(modelConfig: string | File | IModelConfiguration, clearScene?: boolean): ViewerModel;
  447. /**
  448. * load a model using the provided configuration.
  449. * This function, as opposed to initModel, will return a promise that resolves when the model is loaded, and rejects with error.
  450. * If you want to attach to the observables of the model, use initModle instead.
  451. *
  452. * @param modelConfig the model configuration or URL to load.
  453. * @param clearScene Should the scene be cleared before loading the model
  454. * @returns a Promise the fulfills when the model finished loading successfully.
  455. */
  456. loadModel(modelConfig: string | File | IModelConfiguration, clearScene?: boolean): Promise<ViewerModel>;
  457. protected _initTelemetryEvents(): void;
  458. /**
  459. * Injects all the spectre shader in the babylon shader store
  460. */
  461. protected _injectCustomShaders(): void;
  462. }
  463. }
  464. declare module BabylonViewer {
  465. /**
  466. * The data structure of a telemetry event.
  467. */
  468. export interface TelemetryData {
  469. event: string;
  470. session: string;
  471. date: Date;
  472. now: number;
  473. viewerId?: string;
  474. detail: any;
  475. }
  476. /**
  477. * Receives Telemetry events and raises events to the API
  478. */
  479. export class TelemetryManager {
  480. onEventBroadcastedObservable: BABYLON.Observable<TelemetryData>;
  481. /**
  482. * Receives a telemetry event
  483. * @param event The name of the Telemetry event
  484. * @param details An additional value, or an object containing a list of property/value pairs
  485. */
  486. readonly broadcast: (event: string, viewerId?: string | undefined, details?: any) => void;
  487. /**
  488. * Log a Telemetry event for errors raised on the WebGL context.
  489. * @param engine The Babylon engine with the WebGL context.
  490. */
  491. flushWebGLErrors(engine: BABYLON.Engine, viewerId?: string): void;
  492. /**
  493. * Enable or disable telemetry events
  494. * @param enabled Boolan, true if events are enabled
  495. */
  496. enable: boolean;
  497. /**
  498. * Returns the current session ID or creates one if it doesn't exixt
  499. * @return The current session ID
  500. */
  501. readonly session: string;
  502. /**
  503. * Disposes the telemetry manager
  504. */
  505. dispose(): void;
  506. }
  507. export const telemetryManager: TelemetryManager;
  508. }
  509. declare module BabylonViewer {
  510. /**
  511. * An instance of the class is in charge of loading the model correctly.
  512. * This class will continously be expended with tasks required from the specific loaders Babylon has.
  513. *
  514. * A Model loader is unique per (Abstract)Viewer. It is being generated by the viewer
  515. */
  516. export class ModelLoader {
  517. readonly baseUrl: string;
  518. /**
  519. * Create a new Model loader
  520. * @param _viewer the viewer using this model loader
  521. */
  522. constructor(_observablesManager: ObservablesManager, _configurationContainer?: ConfigurationContainer | undefined);
  523. /**
  524. * Adds a new plugin to the loader process.
  525. *
  526. * @param plugin the plugin name or the plugin itself
  527. */
  528. addPlugin(plugin: ILoaderPlugin | string): void;
  529. /**
  530. * Load a model using predefined configuration
  531. * @param modelConfiguration the modelConfiguration to use to load the model
  532. */
  533. load(modelConfiguration: IModelConfiguration): ViewerModel;
  534. cancelLoad(model: ViewerModel): void;
  535. /**
  536. * dispose the model loader.
  537. * If loaders are registered and are in the middle of loading, they will be disposed and the request(s) will be cancelled.
  538. */
  539. dispose(): void;
  540. }
  541. }
  542. declare module BabylonViewer {
  543. /**
  544. * The current state of the model
  545. */
  546. export enum ModelState {
  547. INIT = 0,
  548. LOADING = 1,
  549. LOADED = 2,
  550. ENTRY = 3,
  551. ENTRYDONE = 4,
  552. COMPLETE = 5,
  553. CANCELED = 6,
  554. ERROR = 7
  555. }
  556. /**
  557. * The viewer model is a container for all assets representing a sngle loaded model.
  558. */
  559. export class ViewerModel implements BABYLON.IDisposable {
  560. /**
  561. * The loader used to load this model.
  562. */
  563. loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync;
  564. /**
  565. * This model's root mesh (the parent of all other meshes).
  566. * This mesh does not(!) exist in the meshes array.
  567. */
  568. rootMesh: BABYLON.AbstractMesh;
  569. /**
  570. * ParticleSystems connected to this model
  571. */
  572. particleSystems: Array<BABYLON.IParticleSystem>;
  573. /**
  574. * Skeletons defined in this model
  575. */
  576. skeletons: Array<BABYLON.Skeleton>;
  577. /**
  578. * The current model animation.
  579. * On init, this will be undefined.
  580. */
  581. currentAnimation: IModelAnimation;
  582. /**
  583. * Observers registered here will be executed when the model is done loading
  584. */
  585. onLoadedObservable: BABYLON.Observable<ViewerModel>;
  586. /**
  587. * Observers registered here will be executed when the loader notified of a progress event
  588. */
  589. onLoadProgressObservable: BABYLON.Observable<BABYLON.SceneLoaderProgressEvent>;
  590. /**
  591. * Observers registered here will be executed when the loader notified of an error.
  592. */
  593. onLoadErrorObservable: BABYLON.Observable<{
  594. message: string;
  595. exception: any;
  596. }>;
  597. /**
  598. * Will be executed after the model finished loading and complete, including entry animation and lod
  599. */
  600. onCompleteObservable: BABYLON.Observable<ViewerModel>;
  601. /**
  602. * Observers registered here will be executed every time the model is being configured.
  603. * This can be used to extend the model's configuration without extending the class itself
  604. */
  605. onAfterConfigure: BABYLON.Observable<ViewerModel>;
  606. /**
  607. * The current model state (loaded, error, etc)
  608. */
  609. state: ModelState;
  610. /**
  611. * A loadID provided by the modelLoader, unique to ths (Abstract)Viewer instance.
  612. */
  613. loadId: number;
  614. loadInfo: IAsset;
  615. constructor(_observablesManager: ObservablesManager, modelConfiguration: IModelConfiguration, _configurationContainer?: ConfigurationContainer | undefined);
  616. shadowsRenderedAfterLoad: boolean;
  617. getViewerId(): string | undefined;
  618. /**
  619. * Set whether this model is enabled or not.
  620. */
  621. enabled: boolean;
  622. loaderDone: boolean;
  623. /**
  624. * Add a mesh to this model.
  625. * Any mesh that has no parent will be provided with the root mesh as its new parent.
  626. *
  627. * @param mesh the new mesh to add
  628. * @param triggerLoaded should this mesh trigger the onLoaded observable. Used when adding meshes manually.
  629. */
  630. addMesh(mesh: BABYLON.AbstractMesh, triggerLoaded?: boolean): Promise<ViewerModel> | undefined;
  631. /**
  632. * get the list of meshes (excluding the root mesh)
  633. */
  634. readonly meshes: BABYLON.AbstractMesh[];
  635. /**
  636. * (Re-)set the model's entire configuration
  637. * @param newConfiguration the new configuration to replace the new one
  638. */
  639. configuration: IModelConfiguration;
  640. /**
  641. * Update the current configuration with new values.
  642. * Configuration will not be overwritten, but merged with the new configuration.
  643. * Priority is to the new configuration
  644. * @param newConfiguration the configuration to be merged into the current configuration;
  645. */
  646. updateConfiguration(newConfiguration: Partial<IModelConfiguration>): void;
  647. /**
  648. * Add a new animation group to this model.
  649. * @param animationGroup the new animation group to be added
  650. */
  651. addAnimationGroup(animationGroup: BABYLON.AnimationGroup): void;
  652. /**
  653. * Get the ModelAnimation array
  654. */
  655. getAnimations(): Array<IModelAnimation>;
  656. /**
  657. * Get the animations' names. Using the names you can play a specific animation.
  658. */
  659. getAnimationNames(): Array<string>;
  660. /**
  661. * Get an animation by the provided name. Used mainly when playing n animation.
  662. * @param name the name of the animation to find
  663. */
  664. protected _getAnimationByName(name: string): BABYLON.Nullable<IModelAnimation>;
  665. /**
  666. * Choose an initialized animation using its name and start playing it
  667. * @param name the name of the animation to play
  668. * @returns The model aniamtion to be played.
  669. */
  670. playAnimation(name: string): IModelAnimation;
  671. setCurrentAnimationByName(name: string): IModelAnimation;
  672. /**
  673. * Apply a material configuration to a material
  674. * @param material BABYLON.Material to apply configuration to
  675. * @hidden
  676. */
  677. _applyModelMaterialConfiguration(material: BABYLON.Material): void;
  678. /**
  679. * Begin @animations with the specified @easingFunction
  680. * @param animations The BABYLON Animations to begin
  681. * @param duration of transition, in seconds
  682. * @param easingFunction An easing function to apply
  683. * @param easingMode A easing mode to apply to the easingFunction
  684. * @param onAnimationEnd Call back trigger at the end of the animation.
  685. */
  686. transitionTo(animations: BABYLON.Animation[], duration: number, easingFunction: any, easingMode: number | undefined, // BABYLON.EasingFunction.EASINGMODE_EASEINOUT,
  687. onAnimationEnd: () => void): void;
  688. /**
  689. * Stops and removes all animations that have been applied to the model
  690. */
  691. stopAllAnimations(): void;
  692. /**
  693. * Will remove this model from the viewer (but NOT dispose it).
  694. */
  695. remove(): void;
  696. /**
  697. * Dispose this model, including all of its associated assets.
  698. */
  699. dispose(): void;
  700. }
  701. }
  702. declare module BabylonViewer {
  703. /**
  704. * BABYLON.Animation play mode enum - is the animation looping or playing once
  705. */
  706. export const enum AnimationPlayMode {
  707. ONCE = 0,
  708. LOOP = 1
  709. }
  710. /**
  711. * An enum representing the current state of an animation object
  712. */
  713. export const enum AnimationState {
  714. INIT = 0,
  715. PLAYING = 1,
  716. PAUSED = 2,
  717. STOPPED = 3,
  718. ENDED = 4
  719. }
  720. /**
  721. * The different type of easing functions available
  722. */
  723. export const enum EasingFunction {
  724. Linear = 0,
  725. CircleEase = 1,
  726. BackEase = 2,
  727. BounceEase = 3,
  728. CubicEase = 4,
  729. ElasticEase = 5,
  730. ExponentialEase = 6,
  731. PowerEase = 7,
  732. QuadraticEase = 8,
  733. QuarticEase = 9,
  734. QuinticEase = 10,
  735. SineEase = 11
  736. }
  737. /**
  738. * Defines a simple animation to be applied to a model (scale).
  739. */
  740. export interface ModelAnimationConfiguration {
  741. /**
  742. * Time of animation, in seconds
  743. */
  744. time: number;
  745. /**
  746. * Scale to apply
  747. */
  748. scaling?: BABYLON.Vector3;
  749. /**
  750. * Easing function to apply
  751. * See SPECTRE.EasingFunction
  752. */
  753. easingFunction?: number;
  754. /**
  755. * An Easing mode to apply to the easing function
  756. * See BABYLON.EasingFunction
  757. */
  758. easingMode?: number;
  759. }
  760. /**
  761. * This interface can be implemented to define new types of ModelAnimation objects.
  762. */
  763. export interface IModelAnimation {
  764. /**
  765. * Current animation state (playing, stopped etc')
  766. */
  767. readonly state: AnimationState;
  768. /**
  769. * the name of the animation
  770. */
  771. readonly name: string;
  772. /**
  773. * Get the max numbers of frame available in the animation group
  774. *
  775. * In correlation to an arry, this would be ".length"
  776. */
  777. readonly frames: number;
  778. /**
  779. * Get the current frame playing right now.
  780. * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
  781. *
  782. * In correlation to an array, this would be the current index
  783. */
  784. readonly currentFrame: number;
  785. /**
  786. * BABYLON.Animation's FPS value
  787. */
  788. readonly fps: number;
  789. /**
  790. * Get or set the animation's speed ration (Frame-to-fps)
  791. */
  792. speedRatio: number;
  793. /**
  794. * Gets or sets the aimation's play mode.
  795. */
  796. playMode: AnimationPlayMode;
  797. /**
  798. * Start the animation
  799. */
  800. start(): any;
  801. /**
  802. * Stop the animation.
  803. * This will fail silently if the animation group is already stopped.
  804. */
  805. stop(): any;
  806. /**
  807. * Pause the animation
  808. * This will fail silently if the animation is not currently playing
  809. */
  810. pause(): any;
  811. /**
  812. * Reset this animation
  813. */
  814. reset(): any;
  815. /**
  816. * Restart the animation
  817. */
  818. restart(): any;
  819. /**
  820. * Go to a specific
  821. * @param frameNumber the frame number to go to
  822. */
  823. goToFrame(frameNumber: number): any;
  824. /**
  825. * Dispose this animation
  826. */
  827. dispose(): any;
  828. }
  829. /**
  830. * The GroupModelAnimation is an implementation of the IModelAnimation interface using BABYLON's
  831. * native GroupAnimation class.
  832. */
  833. export class GroupModelAnimation implements IModelAnimation {
  834. /**
  835. * Create a new GroupModelAnimation object using an BABYLON.AnimationGroup object
  836. * @param _animationGroup The aniamtion group to base the class on
  837. */
  838. constructor(_animationGroup: BABYLON.AnimationGroup);
  839. /**
  840. * Get the animation's name
  841. */
  842. readonly name: string;
  843. /**
  844. * Get the current animation's state
  845. */
  846. readonly state: AnimationState;
  847. /**
  848. * Sets the speed ratio to use for all animations
  849. */
  850. speedRatio: number;
  851. /**
  852. * Get the max numbers of frame available in the animation group
  853. *
  854. * In correlation to an arry, this would be ".length"
  855. */
  856. readonly frames: number;
  857. /**
  858. * Get the current frame playing right now.
  859. * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
  860. *
  861. * In correlation to an array, this would be the current index
  862. */
  863. readonly currentFrame: number;
  864. /**
  865. * Get the FPS value of this animation
  866. */
  867. readonly fps: number;
  868. /**
  869. * Set the play mode.
  870. * If the animation is played, it will continue playing at least once more, depending on the new play mode set.
  871. * If the animation is not set, the will be initialized and will wait for the user to start playing it.
  872. */
  873. playMode: AnimationPlayMode;
  874. /**
  875. * Reset the animation group
  876. */
  877. reset(): void;
  878. /**
  879. * Restart the animation group
  880. */
  881. restart(): void;
  882. /**
  883. *
  884. * @param frameNumber Go to a specific frame in the animation
  885. */
  886. goToFrame(frameNumber: number): void;
  887. /**
  888. * Start playing the animation.
  889. */
  890. start(): void;
  891. /**
  892. * Pause the animation
  893. */
  894. pause(): void;
  895. /**
  896. * Stop the animation.
  897. * This will fail silently if the animation group is already stopped.
  898. */
  899. stop(): void;
  900. /**
  901. * Dispose this animation object.
  902. */
  903. dispose(): void;
  904. }
  905. }
  906. declare module BabylonViewer {
  907. /**
  908. * This interface defines the structure of a loader plugin.
  909. * Any of those functions will be called if (!) the loader supports those callbacks.
  910. * Any loader supports onInit, onLoaded, onError and onProgress.
  911. */
  912. export interface ILoaderPlugin {
  913. onInit?: (loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel) => void;
  914. onLoaded?: (model: ViewerModel) => void;
  915. onError?: (message: string, exception?: any) => void;
  916. onProgress?: (progressEvent: BABYLON.SceneLoaderProgressEvent) => void;
  917. onExtensionLoaded?: (extension: BABYLON.IGLTFLoaderExtension) => void;
  918. onParsed?: (parsedData: BABYLON.IGLTFLoaderData) => void;
  919. onMeshLoaded?: (mesh: BABYLON.AbstractMesh) => void;
  920. onTextureLoaded?: (texture: BABYLON.BaseTexture) => void;
  921. onMaterialLoaded?: (material: BABYLON.Material) => void;
  922. onComplete?: () => void;
  923. }
  924. }
  925. declare module BabylonViewer {
  926. export interface IViewerTemplatePlugin {
  927. readonly templateName: string;
  928. readonly eventsToAttach?: Array<string>;
  929. interactionPredicate(event: EventCallback): boolean;
  930. onEvent?(event: EventCallback): void;
  931. addHTMLTemplate?(template: Template): void;
  932. }
  933. export abstract class AbstractViewerNavbarButton implements IViewerTemplatePlugin {
  934. readonly templateName: string;
  935. readonly eventsToAttach: Array<string>;
  936. protected _prepend: boolean;
  937. protected _buttonName: string;
  938. protected _buttonClass: string;
  939. protected _htmlTemplate: string;
  940. constructor(buttonName: string, buttonClass?: string, htmlTemplate?: string);
  941. interactionPredicate(event: EventCallback): boolean;
  942. abstract onEvent(event: EventCallback): void;
  943. addHTMLTemplate(template: Template): void;
  944. protected _generateHTMLElement(template: Template): Element | DocumentFragment;
  945. }
  946. }
  947. declare module BabylonViewer {
  948. /**
  949. *
  950. * @param name the name of the custom optimizer configuration
  951. * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
  952. */
  953. export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
  954. export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
  955. }
  956. declare module BabylonViewer {
  957. /**
  958. * Will attach an init function the the DOMContentLoaded event.
  959. * The init function will be removed automatically after the event was triggered.
  960. */
  961. export function initListeners(): void;
  962. /**
  963. * Select all HTML tags on the page that match the selector and initialize a viewer
  964. *
  965. * @param selector the selector to initialize the viewer on (default is 'babylon')
  966. */
  967. export function InitTags(selector?: string): void;
  968. }
  969. declare module BabylonViewer {
  970. export function getConfigurationKey(key: string, configObject: any): any;
  971. export interface ViewerConfiguration {
  972. version?: string;
  973. extends?: string;
  974. pageUrl?: string;
  975. configuration?: string | {
  976. url?: string;
  977. payload?: any;
  978. mapper?: string;
  979. };
  980. observers?: IObserversConfiguration;
  981. canvasElement?: string;
  982. model?: IModelConfiguration | string;
  983. scene?: ISceneConfiguration;
  984. optimizer?: ISceneOptimizerConfiguration | boolean;
  985. camera?: ICameraConfiguration;
  986. skybox?: boolean | ISkyboxConfiguration;
  987. ground?: boolean | IGroundConfiguration;
  988. lights?: {
  989. [name: string]: number | boolean | ILightConfiguration;
  990. };
  991. engine?: {
  992. renderInBackground?: boolean;
  993. antialiasing?: boolean;
  994. disableResize?: boolean;
  995. engineOptions?: BABYLON.EngineOptions;
  996. adaptiveQuality?: boolean;
  997. hdEnabled?: boolean;
  998. };
  999. templates?: {
  1000. main: ITemplateConfiguration;
  1001. [key: string]: ITemplateConfiguration;
  1002. };
  1003. customShaders?: {
  1004. shaders?: {
  1005. [key: string]: string;
  1006. };
  1007. includes?: {
  1008. [key: string]: string;
  1009. };
  1010. };
  1011. loaderPlugins?: {
  1012. extendedMaterial?: boolean;
  1013. msftLod?: boolean;
  1014. telemetry?: boolean;
  1015. minecraft?: boolean;
  1016. [propName: string]: boolean | undefined;
  1017. };
  1018. environmentMap?: IEnvironmentMapConfiguration;
  1019. vr?: IVRConfiguration;
  1020. lab?: {
  1021. flashlight?: boolean | {
  1022. exponent?: number;
  1023. angle?: number;
  1024. intensity?: number;
  1025. diffuse?: {
  1026. r: number;
  1027. g: number;
  1028. b: number;
  1029. };
  1030. specular?: {
  1031. r: number;
  1032. g: number;
  1033. b: number;
  1034. };
  1035. };
  1036. hideLoadingDelay?: number;
  1037. /** Deprecated */
  1038. assetsRootURL?: string;
  1039. environmentMainColor?: {
  1040. r: number;
  1041. g: number;
  1042. b: number;
  1043. };
  1044. /** Deprecated */
  1045. environmentMap?: {
  1046. /**
  1047. * Environment map texture path in relative to the asset folder.
  1048. */
  1049. texture: string;
  1050. /**
  1051. * Default rotation to apply to the environment map.
  1052. */
  1053. rotationY: number;
  1054. /**
  1055. * Tint level of the main color on the environment map.
  1056. */
  1057. tintLevel: number;
  1058. };
  1059. defaultRenderingPipelines?: boolean | IDefaultRenderingPipelineConfiguration;
  1060. globalLightRotation?: number;
  1061. };
  1062. }
  1063. }
  1064. declare module BabylonViewer {
  1065. /**
  1066. * The object sent when an event is triggered
  1067. */
  1068. export interface EventCallback {
  1069. event: Event;
  1070. template: Template;
  1071. selector: string;
  1072. payload?: any;
  1073. }
  1074. /**
  1075. * The template manager, a member of the viewer class, will manage the viewer's templates and generate the HTML.
  1076. * The template manager managers a single viewer and can be seen as the collection of all sub-templates of the viewer.
  1077. */
  1078. export class TemplateManager {
  1079. containerElement: Element;
  1080. /**
  1081. * Will be triggered when any template is initialized
  1082. */
  1083. onTemplateInit: BABYLON.Observable<Template>;
  1084. /**
  1085. * Will be triggered when any template is fully loaded
  1086. */
  1087. onTemplateLoaded: BABYLON.Observable<Template>;
  1088. /**
  1089. * Will be triggered when a template state changes
  1090. */
  1091. onTemplateStateChange: BABYLON.Observable<Template>;
  1092. /**
  1093. * Will be triggered when all templates finished loading
  1094. */
  1095. onAllLoaded: BABYLON.Observable<TemplateManager>;
  1096. /**
  1097. * Will be triggered when any event on any template is triggered.
  1098. */
  1099. onEventTriggered: BABYLON.Observable<EventCallback>;
  1100. /**
  1101. * This template manager's event manager. In charge of callback registrations to native event types
  1102. */
  1103. eventManager: EventManager;
  1104. constructor(containerElement: Element);
  1105. /**
  1106. * Initialize the template(s) for the viewer. Called bay the Viewer class
  1107. * @param templates the templates to be used to initialize the main template
  1108. */
  1109. initTemplate(templates: {
  1110. [key: string]: ITemplateConfiguration;
  1111. }): Promise<void>;
  1112. /**
  1113. * Get the canvas in the template tree.
  1114. * There must be one and only one canvas inthe template.
  1115. */
  1116. getCanvas(): HTMLCanvasElement | null;
  1117. /**
  1118. * Get a specific template from the template tree
  1119. * @param name the name of the template to load
  1120. */
  1121. getTemplate(name: string): Template | undefined;
  1122. /**
  1123. * Dispose the template manager
  1124. */
  1125. dispose(): void;
  1126. }
  1127. /**
  1128. * This class represents a single template in the viewer's template tree.
  1129. * An example for a template is a single canvas, an overlay (containing sub-templates) or the navigation bar.
  1130. * A template is injected using the template manager in the correct position.
  1131. * The template is rendered using Handlebars and can use Handlebars' features (such as parameter injection)
  1132. *
  1133. * For further information please refer to the documentation page, https://doc.babylonjs.com
  1134. */
  1135. export class Template {
  1136. name: string;
  1137. /**
  1138. * Will be triggered when the template is loaded
  1139. */
  1140. onLoaded: BABYLON.Observable<Template>;
  1141. /**
  1142. * will be triggered when the template is appended to the tree
  1143. */
  1144. onAppended: BABYLON.Observable<Template>;
  1145. /**
  1146. * Will be triggered when the template's state changed (shown, hidden)
  1147. */
  1148. onStateChange: BABYLON.Observable<Template>;
  1149. /**
  1150. * Will be triggered when an event is triggered on ths template.
  1151. * The event is a native browser event (like mouse or pointer events)
  1152. */
  1153. onEventTriggered: BABYLON.Observable<EventCallback>;
  1154. onParamsUpdated: BABYLON.Observable<Template>;
  1155. onHTMLRendered: BABYLON.Observable<Template>;
  1156. /**
  1157. * is the template loaded?
  1158. */
  1159. isLoaded: boolean;
  1160. /**
  1161. * This is meant to be used to track the show and hide functions.
  1162. * This is NOT (!!) a flag to check if the element is actually visible to the user.
  1163. */
  1164. isShown: boolean;
  1165. /**
  1166. * Is this template a part of the HTML tree (the template manager injected it)
  1167. */
  1168. isInHtmlTree: boolean;
  1169. /**
  1170. * The HTML element containing this template
  1171. */
  1172. parent: HTMLElement;
  1173. /**
  1174. * A promise that is fulfilled when the template finished loading.
  1175. */
  1176. initPromise: Promise<Template>;
  1177. constructor(name: string, _configuration: ITemplateConfiguration);
  1178. /**
  1179. * Some templates have parameters (like background color for example).
  1180. * The parameters are provided to Handlebars which in turn generates the template.
  1181. * This function will update the template with the new parameters
  1182. *
  1183. * Note that when updating parameters the events will be registered again (after being cleared).
  1184. *
  1185. * @param params the new template parameters
  1186. */
  1187. updateParams(params: {
  1188. [key: string]: string | number | boolean | object;
  1189. }, append?: boolean): void;
  1190. redraw(): void;
  1191. /**
  1192. * Get the template'S configuration
  1193. */
  1194. readonly configuration: ITemplateConfiguration;
  1195. /**
  1196. * A template can be a parent element for other templates or HTML elements.
  1197. * This function will deliver all child HTML elements of this template.
  1198. */
  1199. getChildElements(): Array<string>;
  1200. /**
  1201. * Appending the template to a parent HTML element.
  1202. * If a parent is already set and you wish to replace the old HTML with new one, forceRemove should be true.
  1203. * @param parent the parent to which the template is added
  1204. * @param forceRemove if the parent already exists, shoud the template be removed from it?
  1205. */
  1206. appendTo(parent: HTMLElement, forceRemove?: boolean): void;
  1207. /**
  1208. * Show the template using the provided visibilityFunction, or natively using display: flex.
  1209. * The provided function returns a promise that should be fullfilled when the element is shown.
  1210. * Since it is a promise async operations are more than possible.
  1211. * See the default viewer for an opacity example.
  1212. * @param visibilityFunction The function to execute to show the template.
  1213. */
  1214. show(visibilityFunction?: (template: Template) => Promise<Template>): Promise<Template>;
  1215. /**
  1216. * Hide the template using the provided visibilityFunction, or natively using display: none.
  1217. * The provided function returns a promise that should be fullfilled when the element is hidden.
  1218. * Since it is a promise async operations are more than possible.
  1219. * See the default viewer for an opacity example.
  1220. * @param visibilityFunction The function to execute to show the template.
  1221. */
  1222. hide(visibilityFunction?: (template: Template) => Promise<Template>): Promise<Template>;
  1223. /**
  1224. * Dispose this template
  1225. */
  1226. dispose(): void;
  1227. }
  1228. }
  1229. declare module BabylonViewer {
  1230. /**
  1231. * The AbstractViewer is the center of Babylon's viewer.
  1232. * It is the basic implementation of the default viewer and is responsible of loading and showing the model and the templates
  1233. */
  1234. export abstract class AbstractViewerWithTemplate extends AbstractViewer {
  1235. protected getConfigurationLoader(): ConfigurationLoader;
  1236. }
  1237. }
  1238. declare module BabylonViewer {
  1239. export class ConfigurationContainer {
  1240. configuration: ViewerConfiguration;
  1241. viewerId: string;
  1242. mainColor: BABYLON.Color3;
  1243. reflectionColor: BABYLON.Color3;
  1244. scene?: BABYLON.Scene;
  1245. }
  1246. }
  1247. declare module BabylonViewer {
  1248. /**
  1249. * The configuration loader will load the configuration object from any source and will use the defined mapper to
  1250. * parse the object and return a conform ViewerConfiguration.
  1251. * It is a private member of the scene.
  1252. */
  1253. export class RenderOnlyConfigurationLoader {
  1254. constructor(_enableCache?: boolean);
  1255. protected getExtendedConfig(type: string | undefined): ViewerConfiguration;
  1256. /**
  1257. * load a configuration object that is defined in the initial configuration provided.
  1258. * The viewer configuration can extend different types of configuration objects and have an extra configuration defined.
  1259. *
  1260. * @param initConfig the initial configuration that has the definitions of further configuration to load.
  1261. * @param callback an optional callback that will be called sync, if noconfiguration needs to be loaded or configuration is payload-only
  1262. * @returns A promise that delivers the extended viewer configuration, when done.
  1263. */
  1264. loadConfiguration(initConfig?: ViewerConfiguration, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration>;
  1265. /**
  1266. * Dispose the configuration loader. This will cancel file requests, if active.
  1267. */
  1268. dispose(): void;
  1269. }
  1270. }
  1271. declare module BabylonViewer {
  1272. export class ObservablesManager {
  1273. /**
  1274. * Will notify when the scene was initialized
  1275. */
  1276. onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
  1277. /**
  1278. * will notify when the engine was initialized
  1279. */
  1280. onEngineInitObservable: BABYLON.Observable<BABYLON.Engine>;
  1281. /**
  1282. * Will notify when a new model was added to the scene.
  1283. * Note that added does not neccessarily mean loaded!
  1284. */
  1285. onModelAddedObservable: BABYLON.Observable<ViewerModel>;
  1286. /**
  1287. * will notify after every model load
  1288. */
  1289. onModelLoadedObservable: BABYLON.Observable<ViewerModel>;
  1290. /**
  1291. * will notify when any model notify of progress
  1292. */
  1293. onModelLoadProgressObservable: BABYLON.Observable<BABYLON.SceneLoaderProgressEvent>;
  1294. /**
  1295. * will notify when any model load failed.
  1296. */
  1297. onModelLoadErrorObservable: BABYLON.Observable<{
  1298. message: string;
  1299. exception: any;
  1300. }>;
  1301. /**
  1302. * Will notify when a model was removed from the scene;
  1303. */
  1304. onModelRemovedObservable: BABYLON.Observable<ViewerModel>;
  1305. /**
  1306. * will notify when a new loader was initialized.
  1307. * Used mainly to know when a model starts loading.
  1308. */
  1309. onLoaderInitObservable: BABYLON.Observable<BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync>;
  1310. /**
  1311. * Observers registered here will be executed when the entire load process has finished.
  1312. */
  1313. onViewerInitDoneObservable: BABYLON.Observable<any>;
  1314. /**
  1315. * Will notify when the viewer init started (after configuration was loaded)
  1316. */
  1317. onViewerInitStartedObservable: BABYLON.Observable<any>;
  1318. /**
  1319. * Functions added to this observable will be executed on each frame rendered.
  1320. */
  1321. onFrameRenderedObservable: BABYLON.Observable<any>;
  1322. /**
  1323. * Will notify when VR mode is entered.
  1324. */
  1325. onEnteringVRObservable: BABYLON.Observable<any>;
  1326. /**
  1327. * Will notify when VR mode is exited.
  1328. */
  1329. onExitingVRObservable: BABYLON.Observable<any>;
  1330. constructor();
  1331. dispose(): void;
  1332. }
  1333. }
  1334. declare module BabylonViewer {
  1335. /**
  1336. * This interface describes the structure of the variable sent with the configuration observables of the scene manager.
  1337. * O - the type of object we are dealing with (Light, BABYLON.ArcRotateCamera, BABYLON.Scene, etc')
  1338. * T - the configuration type
  1339. */
  1340. export interface IPostConfigurationCallback<OBJ, CONF> {
  1341. newConfiguration: CONF;
  1342. sceneManager: SceneManager;
  1343. object: OBJ;
  1344. model?: ViewerModel;
  1345. }
  1346. export class SceneManager {
  1347. /**
  1348. * Will notify when the scene was initialized
  1349. */
  1350. onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
  1351. /**
  1352. * Will notify after the scene was configured. Can be used to further configure the scene
  1353. */
  1354. onSceneConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.Scene, ISceneConfiguration>>;
  1355. /**
  1356. * Will notify after the scene optimized was configured. Can be used to further configure the scene optimizer
  1357. */
  1358. onSceneOptimizerConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.SceneOptimizer, ISceneOptimizerConfiguration | boolean>>;
  1359. /**
  1360. * Will notify after the camera was configured. Can be used to further configure the camera
  1361. */
  1362. onCameraConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.ArcRotateCamera, ICameraConfiguration>>;
  1363. /**
  1364. * Will notify after the lights were configured. Can be used to further configure lights
  1365. */
  1366. onLightsConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<Array<BABYLON.Light>, {
  1367. [name: string]: ILightConfiguration | boolean | number;
  1368. }>>;
  1369. /**
  1370. * Will notify after the model(s) were configured. Can be used to further configure models
  1371. */
  1372. onModelsConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<Array<ViewerModel>, IModelConfiguration>>;
  1373. /**
  1374. * Will notify after the envirnoment was configured. Can be used to further configure the environment
  1375. */
  1376. onEnvironmentConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.EnvironmentHelper, {
  1377. skybox?: ISkyboxConfiguration | boolean;
  1378. ground?: IGroundConfiguration | boolean;
  1379. }>>;
  1380. /**
  1381. * Will notify after the model(s) were configured. Can be used to further configure models
  1382. */
  1383. onVRConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.VRExperienceHelper, IVRConfiguration>>;
  1384. /**
  1385. * The Babylon BABYLON.Scene of this viewer
  1386. */
  1387. scene: BABYLON.Scene;
  1388. /**
  1389. * The camera used in this viewer
  1390. */
  1391. camera: BABYLON.ArcRotateCamera;
  1392. /**
  1393. * Babylon's scene optimizer
  1394. */
  1395. sceneOptimizer: BABYLON.SceneOptimizer;
  1396. /**
  1397. * Models displayed in this viewer.
  1398. */
  1399. models: Array<ViewerModel>;
  1400. /**
  1401. * Babylon's environment helper of this viewer
  1402. */
  1403. environmentHelper?: BABYLON.EnvironmentHelper;
  1404. protected _defaultHighpTextureType: number;
  1405. protected _shadowGeneratorBias: number;
  1406. protected _defaultPipelineTextureType: number;
  1407. /**
  1408. * The maximum number of shadows supported by the curent viewer
  1409. */
  1410. protected _maxShadows: number;
  1411. /**
  1412. * The labs variable consists of objects that will have their API change.
  1413. * Please be careful when using labs in production.
  1414. */
  1415. labs: ViewerLabs;
  1416. readonly defaultRenderingPipeline: BABYLON.Nullable<BABYLON.DefaultRenderingPipeline>;
  1417. protected _vrHelper?: BABYLON.VRExperienceHelper;
  1418. readonly vrHelper: BABYLON.VRExperienceHelper | undefined;
  1419. constructor(_engine: BABYLON.Engine, _configurationContainer: ConfigurationContainer, _observablesManager?: ObservablesManager | undefined);
  1420. /**
  1421. * Returns a boolean representing HDR support
  1422. */
  1423. readonly isHdrSupported: boolean;
  1424. /**
  1425. * Return the main color defined in the configuration.
  1426. */
  1427. readonly mainColor: BABYLON.Color3;
  1428. readonly reflectionColor: BABYLON.Color3;
  1429. animationBlendingEnabled: boolean;
  1430. readonly observablesManager: ObservablesManager | undefined;
  1431. /**
  1432. * Should shadows be rendered every frame, or only once and stop.
  1433. * This can be used to optimize a scene.
  1434. *
  1435. * Not that the shadows will NOT disapear but will remain in place.
  1436. * @param process if true shadows will be updated once every frame. if false they will stop being updated.
  1437. */
  1438. processShadows: boolean;
  1439. groundEnabled: boolean;
  1440. /**
  1441. * sets wether the reflection is disabled.
  1442. */
  1443. groundMirrorEnabled: boolean;
  1444. defaultRenderingPipelineEnabled: boolean;
  1445. /**
  1446. * Sets the engine flags to unlock all babylon features.
  1447. * Can also be configured using the scene.flags configuration object
  1448. */
  1449. unlockBabylonFeatures(): void;
  1450. /**
  1451. * initialize the scene. Calling this function again will dispose the old scene, if exists.
  1452. */
  1453. initScene(sceneConfiguration?: ISceneConfiguration, optimizerConfiguration?: boolean | ISceneOptimizerConfiguration): Promise<BABYLON.Scene>;
  1454. clearScene(clearModels?: boolean, clearLights?: boolean): void;
  1455. /**
  1456. * This will update the scene's configuration, including camera, lights, environment.
  1457. * @param newConfiguration the delta that should be configured. This includes only the changes
  1458. * @param globalConfiguration The global configuration object, after the new configuration was merged into it
  1459. */
  1460. updateConfiguration(newConfiguration: Partial<ViewerConfiguration>): void;
  1461. bloomEnabled: boolean;
  1462. fxaaEnabled: boolean;
  1463. setDefaultMaterial(sceneConfig: ISceneConfiguration): void;
  1464. /**
  1465. * internally configure the scene using the provided configuration.
  1466. * The scene will not be recreated, but just updated.
  1467. * @param sceneConfig the (new) scene configuration
  1468. */
  1469. protected _configureScene(sceneConfig: ISceneConfiguration): void;
  1470. /**
  1471. * Configure the scene optimizer.
  1472. * The existing scene optimizer will be disposed and a new one will be created.
  1473. * @param optimizerConfig the (new) optimizer configuration
  1474. */
  1475. protected _configureOptimizer(optimizerConfig: ISceneOptimizerConfiguration | boolean): void;
  1476. /**
  1477. * configure all models using the configuration.
  1478. * @param modelConfiguration the configuration to use to reconfigure the models
  1479. */
  1480. protected _configureVR(vrConfig: IVRConfiguration): void;
  1481. protected _configureEnvironmentMap(environmentMapConfiguration: IEnvironmentMapConfiguration): any;
  1482. /**
  1483. * (Re) configure the camera. The camera will only be created once and from this point will only be reconfigured.
  1484. * @param cameraConfig the new camera configuration
  1485. * @param model optionally use the model to configure the camera.
  1486. */
  1487. protected _configureCamera(cameraConfig?: ICameraConfiguration): void;
  1488. protected _configureEnvironment(skyboxConifguration?: ISkyboxConfiguration | boolean, groundConfiguration?: IGroundConfiguration | boolean): void;
  1489. /**
  1490. * configure the lights.
  1491. *
  1492. * @param lightsConfiguration the (new) light(s) configuration
  1493. * @param model optionally use the model to configure the camera.
  1494. */
  1495. protected _configureLights(lightsConfiguration?: {
  1496. [name: string]: ILightConfiguration | boolean | number;
  1497. }): void;
  1498. /**
  1499. * Gets the shadow map blur kernel according to the light configuration.
  1500. * @param light The light used to generate the shadows
  1501. * @param bufferSize The size of the shadow map
  1502. * @return the kernel blur size
  1503. */
  1504. getBlurKernel(light: BABYLON.IShadowLight, bufferSize: number): number;
  1505. /**
  1506. * Alters render settings to reduce features based on hardware feature limitations
  1507. * @param enableHDR Allows the viewer to run in HDR mode.
  1508. */
  1509. protected _handleHardwareLimitations(enableHDR?: boolean): void;
  1510. /**
  1511. * Dispoe the entire viewer including the scene and the engine
  1512. */
  1513. dispose(): void;
  1514. }
  1515. }
  1516. declare module BabylonViewer {
  1517. export interface IModelConfiguration {
  1518. id?: string;
  1519. url?: string;
  1520. root?: string;
  1521. file?: string | File;
  1522. loader?: string;
  1523. position?: {
  1524. x: number;
  1525. y: number;
  1526. z: number;
  1527. };
  1528. rotation?: {
  1529. x: number;
  1530. y: number;
  1531. z: number;
  1532. w?: number;
  1533. };
  1534. scaling?: {
  1535. x: number;
  1536. y: number;
  1537. z: number;
  1538. };
  1539. parentObjectIndex?: number;
  1540. castShadow?: boolean;
  1541. receiveShadows?: boolean;
  1542. normalize?: boolean | {
  1543. center?: boolean;
  1544. unitSize?: boolean;
  1545. parentIndex?: number;
  1546. };
  1547. title?: string;
  1548. subtitle?: string;
  1549. thumbnail?: string;
  1550. animation?: {
  1551. autoStart?: boolean | string;
  1552. playOnce?: boolean;
  1553. autoStartIndex?: number;
  1554. };
  1555. entryAnimation?: IModelAnimationConfiguration;
  1556. exitAnimation?: IModelAnimationConfiguration;
  1557. material?: {
  1558. directEnabled?: boolean;
  1559. directIntensity?: number;
  1560. emissiveIntensity?: number;
  1561. environmentIntensity?: number;
  1562. [propName: string]: any;
  1563. };
  1564. /**
  1565. * Rotation offset axis definition
  1566. */
  1567. rotationOffsetAxis?: {
  1568. x: number;
  1569. y: number;
  1570. z: number;
  1571. };
  1572. /**
  1573. * the offset angle
  1574. */
  1575. rotationOffsetAngle?: number;
  1576. loaderConfiguration?: {
  1577. maxLODsToLoad?: number;
  1578. progressiveLoading?: boolean;
  1579. };
  1580. }
  1581. }
  1582. declare module BabylonViewer {
  1583. /**
  1584. * Get a loader plugin according to its name.
  1585. * The plugin will be cached and will be reused if called for again.
  1586. *
  1587. * @param name the name of the plugin
  1588. */
  1589. export function getLoaderPluginByName(name: string): ILoaderPlugin;
  1590. /**
  1591. *
  1592. */
  1593. export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
  1594. }
  1595. declare module BabylonViewer {
  1596. export interface IEnvironmentMapConfiguration {
  1597. /**
  1598. * Environment map texture path in relative to the asset folder.
  1599. */
  1600. texture: string;
  1601. /**
  1602. * Default rotation to apply to the environment map.
  1603. */
  1604. rotationY: number;
  1605. /**
  1606. * Tint level of the main color on the environment map.
  1607. */
  1608. tintLevel: number;
  1609. /**
  1610. * The environment's main color.
  1611. */
  1612. mainColor?: {
  1613. r?: number;
  1614. g?: number;
  1615. b?: number;
  1616. };
  1617. }
  1618. }
  1619. declare module BabylonViewer {
  1620. /**
  1621. * The EventManager is in charge of registering user interctions with the viewer.
  1622. * It is used in the TemplateManager
  1623. */
  1624. export class EventManager {
  1625. constructor(_templateManager: TemplateManager);
  1626. /**
  1627. * Register a new callback to a specific template.
  1628. * The best example for the usage can be found in the DefaultViewer
  1629. *
  1630. * @param templateName the templateName to register the event to
  1631. * @param callback The callback to be executed
  1632. * @param eventType the type of event to register
  1633. * @param selector an optional selector. if not defined the parent object in the template will be selected
  1634. */
  1635. registerCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
  1636. /**
  1637. * This will remove a registered event from the defined template.
  1638. * Each one of the variables apart from the template name are optional, but one must be provided.
  1639. *
  1640. * @param templateName the templateName
  1641. * @param callback the callback to remove (optional)
  1642. * @param eventType the event type to remove (optional)
  1643. * @param selector the selector from which to remove the event (optional)
  1644. */
  1645. unregisterCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
  1646. /**
  1647. * Dispose the event manager
  1648. */
  1649. dispose(): void;
  1650. }
  1651. }
  1652. declare module BabylonViewer {
  1653. export class ConfigurationLoader extends RenderOnlyConfigurationLoader {
  1654. protected getExtendedConfig(type: string | undefined): import("babylonjs-viewer/configuration/configuration").ViewerConfiguration;
  1655. }
  1656. }
  1657. declare module BabylonViewer {
  1658. /**
  1659. * Defines an animation to be applied to a model (translation, scale or rotation).
  1660. */
  1661. export interface IModelAnimationConfiguration {
  1662. /**
  1663. * Time of animation, in seconds
  1664. */
  1665. time?: number;
  1666. /**
  1667. * Scale to apply
  1668. */
  1669. scaling?: {
  1670. x: number;
  1671. y: number;
  1672. z: number;
  1673. };
  1674. /**
  1675. * Easing function to apply
  1676. */
  1677. easingFunction?: number;
  1678. /**
  1679. * An Easing mode to apply to the easing function
  1680. * See BABYLON.EasingFunction
  1681. */
  1682. easingMode?: number;
  1683. }
  1684. }
  1685. declare module BabylonViewer {
  1686. export class TelemetryLoaderPlugin implements ILoaderPlugin {
  1687. onInit(loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel): void;
  1688. onLoaded(model: ViewerModel): void;
  1689. onError(message: string, exception: any): void;
  1690. onComplete(): void;
  1691. }
  1692. }
  1693. declare module BabylonViewer {
  1694. /**
  1695. * A loder plugin to use MSFT_lod extension correctly (glTF)
  1696. */
  1697. export class MSFTLodLoaderPlugin implements ILoaderPlugin {
  1698. onInit(loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel): void;
  1699. onExtensionLoaded(extension: BABYLON.IGLTFLoaderExtension): void;
  1700. }
  1701. }
  1702. declare module BabylonViewer {
  1703. /**
  1704. * Force-apply material configuration right after a material was loaded.
  1705. */
  1706. export class ApplyMaterialConfigPlugin implements ILoaderPlugin {
  1707. onInit(loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel): void;
  1708. onMaterialLoaded(material: BABYLON.Material): void;
  1709. }
  1710. }
  1711. declare module BabylonViewer {
  1712. /**
  1713. * A (PBR) material will be extended using this function.
  1714. * This function will hold extra default configuration for the viewer, if not implemented in Babylon itself.
  1715. */
  1716. export class ExtendedMaterialLoaderPlugin implements ILoaderPlugin {
  1717. onMaterialLoaded(baseMaterial: BABYLON.Material): void;
  1718. }
  1719. }
  1720. declare module BabylonViewer {
  1721. export interface ICameraConfiguration {
  1722. position?: {
  1723. x: number;
  1724. y: number;
  1725. z: number;
  1726. };
  1727. rotation?: {
  1728. x: number;
  1729. y: number;
  1730. z: number;
  1731. w: number;
  1732. };
  1733. fov?: number;
  1734. fovMode?: number;
  1735. minZ?: number;
  1736. maxZ?: number;
  1737. inertia?: number;
  1738. exposure?: number;
  1739. pinchPrecision?: number;
  1740. behaviors?: {
  1741. [name: string]: boolean | number | ICameraBehaviorConfiguration;
  1742. };
  1743. disableCameraControl?: boolean;
  1744. disableCtrlForPanning?: boolean;
  1745. disableAutoFocus?: boolean;
  1746. [propName: string]: any;
  1747. }
  1748. export interface ICameraBehaviorConfiguration {
  1749. type: number;
  1750. [propName: string]: any;
  1751. }
  1752. }
  1753. declare module BabylonViewer {
  1754. /**
  1755. * The Color Grading Configuration groups the different settings used to define the color grading used in the viewer.
  1756. */
  1757. export interface IColorGradingConfiguration {
  1758. /**
  1759. * Transform data string, encoded as determined by transformDataFormat.
  1760. */
  1761. transformData: string;
  1762. /**
  1763. * The encoding format of TransformData (currently only raw-base16 is supported).
  1764. */
  1765. transformDataFormat: string;
  1766. /**
  1767. * The weight of the transform
  1768. */
  1769. transformWeight: number;
  1770. /**
  1771. * Color curve colorFilterHueGlobal value
  1772. */
  1773. colorFilterHueGlobal: number;
  1774. /**
  1775. * Color curve colorFilterHueShadows value
  1776. */
  1777. colorFilterHueShadows: number;
  1778. /**
  1779. * Color curve colorFilterHueMidtones value
  1780. */
  1781. colorFilterHueMidtones: number;
  1782. /**
  1783. * Color curve colorFilterHueHighlights value
  1784. */
  1785. colorFilterHueHighlights: number;
  1786. /**
  1787. * Color curve colorFilterDensityGlobal value
  1788. */
  1789. colorFilterDensityGlobal: number;
  1790. /**
  1791. * Color curve colorFilterDensityShadows value
  1792. */
  1793. colorFilterDensityShadows: number;
  1794. /**
  1795. * Color curve colorFilterDensityMidtones value
  1796. */
  1797. colorFilterDensityMidtones: number;
  1798. /**
  1799. * Color curve colorFilterDensityHighlights value
  1800. */
  1801. colorFilterDensityHighlights: number;
  1802. /**
  1803. * Color curve saturationGlobal value
  1804. */
  1805. saturationGlobal: number;
  1806. /**
  1807. * Color curve saturationShadows value
  1808. */
  1809. saturationShadows: number;
  1810. /**
  1811. * Color curve saturationMidtones value
  1812. */
  1813. saturationMidtones: number;
  1814. /**
  1815. * Color curve saturationHighlights value
  1816. */
  1817. saturationHighlights: number;
  1818. /**
  1819. * Color curve exposureGlobal value
  1820. */
  1821. exposureGlobal: number;
  1822. /**
  1823. * Color curve exposureShadows value
  1824. */
  1825. exposureShadows: number;
  1826. /**
  1827. * Color curve exposureMidtones value
  1828. */
  1829. exposureMidtones: number;
  1830. /**
  1831. * Color curve exposureHighlights value
  1832. */
  1833. exposureHighlights: number;
  1834. }
  1835. }
  1836. declare module BabylonViewer {
  1837. export interface IDefaultRenderingPipelineConfiguration {
  1838. sharpenEnabled?: boolean;
  1839. bloomEnabled?: boolean;
  1840. bloomThreshold?: number;
  1841. depthOfFieldEnabled?: boolean;
  1842. depthOfFieldBlurLevel?: BABYLON.DepthOfFieldEffectBlurLevel;
  1843. fxaaEnabled?: boolean;
  1844. imageProcessingEnabled?: boolean;
  1845. defaultPipelineTextureType?: number;
  1846. bloomScale?: number;
  1847. chromaticAberrationEnabled?: boolean;
  1848. grainEnabled?: boolean;
  1849. bloomKernel?: number;
  1850. hardwareScaleLevel?: number;
  1851. bloomWeight?: number;
  1852. hdr?: boolean;
  1853. samples?: number;
  1854. glowLayerEnabled?: boolean;
  1855. }
  1856. }
  1857. declare module BabylonViewer {
  1858. export interface IGroundConfiguration {
  1859. size?: number;
  1860. receiveShadows?: boolean;
  1861. shadowLevel?: number;
  1862. shadowOnly?: boolean;
  1863. mirror?: boolean | {
  1864. sizeRatio?: number;
  1865. blurKernel?: number;
  1866. amount?: number;
  1867. fresnelWeight?: number;
  1868. fallOffDistance?: number;
  1869. textureType?: number;
  1870. };
  1871. texture?: string;
  1872. color?: {
  1873. r: number;
  1874. g: number;
  1875. b: number;
  1876. };
  1877. opacity?: number;
  1878. material?: {
  1879. [propName: string]: any;
  1880. };
  1881. }
  1882. }
  1883. declare module BabylonViewer {
  1884. export interface IImageProcessingConfiguration {
  1885. colorGradingEnabled?: boolean;
  1886. colorCurvesEnabled?: boolean;
  1887. colorCurves?: {
  1888. globalHue?: number;
  1889. globalDensity?: number;
  1890. globalSaturation?: number;
  1891. globalExposure?: number;
  1892. highlightsHue?: number;
  1893. highlightsDensity?: number;
  1894. highlightsSaturation?: number;
  1895. highlightsExposure?: number;
  1896. midtonesHue?: number;
  1897. midtonesDensity?: number;
  1898. midtonesSaturation?: number;
  1899. midtonesExposure?: number;
  1900. shadowsHue?: number;
  1901. shadowsDensity?: number;
  1902. shadowsSaturation?: number;
  1903. shadowsExposure?: number;
  1904. };
  1905. colorGradingWithGreenDepth?: boolean;
  1906. colorGradingBGR?: boolean;
  1907. exposure?: number;
  1908. toneMappingEnabled?: boolean;
  1909. contrast?: number;
  1910. vignetteEnabled?: boolean;
  1911. vignetteStretch?: number;
  1912. vignetteCentreX?: number;
  1913. vignetteCentreY?: number;
  1914. vignetteWeight?: number;
  1915. vignetteColor?: {
  1916. r: number;
  1917. g: number;
  1918. b: number;
  1919. a?: number;
  1920. };
  1921. vignetteCameraFov?: number;
  1922. vignetteBlendMode?: number;
  1923. vignetteM?: boolean;
  1924. applyByPostProcess?: boolean;
  1925. isEnabled?: boolean;
  1926. }
  1927. }
  1928. declare module BabylonViewer {
  1929. export interface ILightConfiguration {
  1930. type: number;
  1931. name?: string;
  1932. disabled?: boolean;
  1933. position?: {
  1934. x: number;
  1935. y: number;
  1936. z: number;
  1937. };
  1938. target?: {
  1939. x: number;
  1940. y: number;
  1941. z: number;
  1942. };
  1943. direction?: {
  1944. x: number;
  1945. y: number;
  1946. z: number;
  1947. };
  1948. diffuse?: {
  1949. r: number;
  1950. g: number;
  1951. b: number;
  1952. };
  1953. specular?: {
  1954. r: number;
  1955. g: number;
  1956. b: number;
  1957. };
  1958. intensity?: number;
  1959. intensityMode?: number;
  1960. radius?: number;
  1961. shadownEnabled?: boolean;
  1962. shadowConfig?: {
  1963. useBlurExponentialShadowMap?: boolean;
  1964. useBlurCloseExponentialShadowMap?: boolean;
  1965. useKernelBlur?: boolean;
  1966. blurKernel?: number;
  1967. blurScale?: number;
  1968. minZ?: number;
  1969. maxZ?: number;
  1970. frustumSize?: number;
  1971. angleScale?: number;
  1972. frustumEdgeFalloff?: number;
  1973. [propName: string]: any;
  1974. };
  1975. spotAngle?: number;
  1976. shadowFieldOfView?: number;
  1977. shadowBufferSize?: number;
  1978. shadowFrustumSize?: number;
  1979. shadowMinZ?: number;
  1980. shadowMaxZ?: number;
  1981. [propName: string]: any;
  1982. behaviors?: {
  1983. [name: string]: number | {
  1984. type: number;
  1985. [propName: string]: any;
  1986. };
  1987. };
  1988. }
  1989. }
  1990. declare module BabylonViewer {
  1991. export interface IObserversConfiguration {
  1992. onEngineInit?: string;
  1993. onSceneInit?: string;
  1994. onModelLoaded?: string;
  1995. }
  1996. }
  1997. declare module BabylonViewer {
  1998. export interface ISceneConfiguration {
  1999. debug?: boolean;
  2000. clearColor?: {
  2001. r: number;
  2002. g: number;
  2003. b: number;
  2004. a: number;
  2005. };
  2006. /** Deprecated, use environmentMap.mainColor instead. */
  2007. mainColor?: {
  2008. r?: number;
  2009. g?: number;
  2010. b?: number;
  2011. };
  2012. imageProcessingConfiguration?: IImageProcessingConfiguration;
  2013. environmentTexture?: string;
  2014. colorGrading?: IColorGradingConfiguration;
  2015. environmentRotationY?: number;
  2016. /**
  2017. * Deprecated, please use default rendering pipeline
  2018. */
  2019. glow?: boolean | BABYLON.IGlowLayerOptions;
  2020. disableHdr?: boolean;
  2021. renderInBackground?: boolean;
  2022. disableCameraControl?: boolean;
  2023. animationPropertiesOverride?: {
  2024. [propName: string]: any;
  2025. };
  2026. defaultMaterial?: {
  2027. materialType: "standard" | "pbr";
  2028. [propName: string]: any;
  2029. };
  2030. flags?: {
  2031. shadowsEnabled?: boolean;
  2032. particlesEnabled?: boolean;
  2033. collisionsEnabled?: boolean;
  2034. lightsEnabled?: boolean;
  2035. texturesEnabled?: boolean;
  2036. lensFlaresEnabled?: boolean;
  2037. proceduralTexturesEnabled?: boolean;
  2038. renderTargetsEnabled?: boolean;
  2039. spritesEnabled?: boolean;
  2040. skeletonsEnabled?: boolean;
  2041. audioEnabled?: boolean;
  2042. };
  2043. assetsRootURL?: string;
  2044. }
  2045. }
  2046. declare module BabylonViewer {
  2047. export interface ISceneOptimizerConfiguration {
  2048. targetFrameRate?: number;
  2049. trackerDuration?: number;
  2050. autoGeneratePriorities?: boolean;
  2051. improvementMode?: boolean;
  2052. degradation?: string;
  2053. types?: {
  2054. texture?: ISceneOptimizerParameters;
  2055. hardwareScaling?: ISceneOptimizerParameters;
  2056. shadow?: ISceneOptimizerParameters;
  2057. postProcess?: ISceneOptimizerParameters;
  2058. lensFlare?: ISceneOptimizerParameters;
  2059. particles?: ISceneOptimizerParameters;
  2060. renderTarget?: ISceneOptimizerParameters;
  2061. mergeMeshes?: ISceneOptimizerParameters;
  2062. };
  2063. custom?: string;
  2064. }
  2065. export interface ISceneOptimizerParameters {
  2066. priority?: number;
  2067. maximumSize?: number;
  2068. step?: number;
  2069. }
  2070. }
  2071. declare module BabylonViewer {
  2072. export interface ISkyboxConfiguration {
  2073. cubeTexture?: {
  2074. noMipMap?: boolean;
  2075. gammaSpace?: boolean;
  2076. url?: string | Array<string>;
  2077. };
  2078. color?: {
  2079. r: number;
  2080. g: number;
  2081. b: number;
  2082. };
  2083. pbr?: boolean;
  2084. scale?: number;
  2085. blur?: number;
  2086. material?: {
  2087. imageProcessingConfiguration?: IImageProcessingConfiguration;
  2088. [propName: string]: any;
  2089. };
  2090. infiniteDistance?: boolean;
  2091. }
  2092. }
  2093. declare module BabylonViewer {
  2094. /**
  2095. * A single template configuration object
  2096. */
  2097. export interface ITemplateConfiguration {
  2098. /**
  2099. * can be either the id of the template's html element or a URL.
  2100. * See - http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
  2101. */
  2102. location?: string;
  2103. /**
  2104. * If no location is provided you can provide here the raw html of this template.
  2105. * See http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
  2106. */
  2107. html?: string;
  2108. id?: string;
  2109. /**
  2110. * Parameters that will be delivered to the template and will render it accordingly.
  2111. */
  2112. params?: {
  2113. [key: string]: string | number | boolean | object;
  2114. };
  2115. /**
  2116. * Events to attach to this template.
  2117. * event name is the key. the value can either be a boolean (attach to the parent element)
  2118. * or a map of html id elements.
  2119. *
  2120. * See - http://doc.babylonjs.com/extensions/the_templating_system#event-binding
  2121. */
  2122. events?: {
  2123. pointerdown?: boolean | {
  2124. [id: string]: boolean;
  2125. };
  2126. pointerup?: boolean | {
  2127. [id: string]: boolean;
  2128. };
  2129. pointermove?: boolean | {
  2130. [id: string]: boolean;
  2131. };
  2132. pointerover?: boolean | {
  2133. [id: string]: boolean;
  2134. };
  2135. pointerout?: boolean | {
  2136. [id: string]: boolean;
  2137. };
  2138. pointerenter?: boolean | {
  2139. [id: string]: boolean;
  2140. };
  2141. pointerleave?: boolean | {
  2142. [id: string]: boolean;
  2143. };
  2144. pointercancel?: boolean | {
  2145. [id: string]: boolean;
  2146. };
  2147. click?: boolean | {
  2148. [id: string]: boolean;
  2149. };
  2150. dragstart?: boolean | {
  2151. [id: string]: boolean;
  2152. };
  2153. drop?: boolean | {
  2154. [id: string]: boolean;
  2155. };
  2156. [key: string]: boolean | {
  2157. [id: string]: boolean;
  2158. } | undefined;
  2159. };
  2160. }
  2161. }
  2162. declare module BabylonViewer {
  2163. export interface IVRConfiguration {
  2164. disabled?: boolean;
  2165. objectScaleFactor?: number;
  2166. disableInteractions?: boolean;
  2167. disableTeleportation?: boolean;
  2168. overrideFloorMeshName?: string;
  2169. vrOptions?: BABYLON.VRExperienceHelperOptions;
  2170. modelHeightCorrection?: number | boolean;
  2171. rotateUsingControllers?: boolean;
  2172. cameraPosition?: {
  2173. x: number;
  2174. y: number;
  2175. z: number;
  2176. };
  2177. }
  2178. }