babylon.viewer.module.d.ts 104 KB

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