babylon.viewer.d.ts 95 KB

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