babylon.viewer.d.ts 105 KB

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