babylon.viewer.module.d.ts 113 KB

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