babylon.viewer.d.ts 105 KB

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