babylon.viewer.module.d.ts 107 KB

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