babylon.viewer.d.ts 105 KB

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