babylon.viewer.module.d.ts 113 KB

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