babylon.viewer.module.d.ts 106 KB

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