babylon.viewer.d.ts 105 KB

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