babylon.viewer.module.d.ts 113 KB

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