babylon.viewer.module.d.ts 113 KB

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