babylon.viewer.module.d.ts 110 KB

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