babylon.viewer.module.d.ts 113 KB

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