babylon.viewer.module.d.ts 113 KB

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