babylon.viewer.module.d.ts 113 KB

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