babylon.viewer.d.ts 105 KB

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