babylon.viewer.module.d.ts 113 KB

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