babylon.viewer.module.d.ts 109 KB

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