babylon.viewer.module.d.ts 114 KB

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