babylon.viewer.module.d.ts 113 KB

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