babylon.viewer.module.d.ts 110 KB

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