babylon.viewer.module.d.ts 109 KB

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