babylon.viewer.module.d.ts 110 KB

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