babylon.viewer.module.d.ts 109 KB

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