babylon.viewer.d.ts 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504
  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. * Will attach an init function the the DOMContentLoaded event.
  950. * The init function will be removed automatically after the event was triggered.
  951. */
  952. export function initListeners(): void;
  953. /**
  954. * Select all HTML tags on the page that match the selector and initialize a viewer
  955. *
  956. * @param selector the selector to initialize the viewer on (default is 'babylon')
  957. */
  958. export function InitTags(selector?: string): void;
  959. }
  960. declare module BabylonViewer {
  961. export function getConfigurationKey(key: string, configObject: any): any;
  962. export interface ViewerConfiguration {
  963. version?: string;
  964. extends?: string;
  965. pageUrl?: string;
  966. configuration?: string | {
  967. url?: string;
  968. payload?: any;
  969. mapper?: string;
  970. };
  971. observers?: IObserversConfiguration;
  972. canvasElement?: string;
  973. model?: IModelConfiguration | string;
  974. scene?: ISceneConfiguration;
  975. optimizer?: ISceneOptimizerConfiguration | boolean;
  976. camera?: ICameraConfiguration;
  977. skybox?: boolean | ISkyboxConfiguration;
  978. ground?: boolean | IGroundConfiguration;
  979. lights?: {
  980. [name: string]: number | boolean | ILightConfiguration;
  981. };
  982. engine?: {
  983. renderInBackground?: boolean;
  984. antialiasing?: boolean;
  985. disableResize?: boolean;
  986. engineOptions?: BABYLON.EngineOptions;
  987. adaptiveQuality?: boolean;
  988. hdEnabled?: boolean;
  989. };
  990. templates?: {
  991. main: ITemplateConfiguration;
  992. [key: string]: ITemplateConfiguration;
  993. };
  994. customShaders?: {
  995. shaders?: {
  996. [key: string]: string;
  997. };
  998. includes?: {
  999. [key: string]: string;
  1000. };
  1001. };
  1002. loaderPlugins?: {
  1003. extendedMaterial?: boolean;
  1004. msftLod?: boolean;
  1005. telemetry?: boolean;
  1006. minecraft?: boolean;
  1007. [propName: string]: boolean | undefined;
  1008. };
  1009. environmentMap?: IEnvironmentMapConfiguration;
  1010. vr?: IVRConfiguration;
  1011. lab?: {
  1012. flashlight?: boolean | {
  1013. exponent?: number;
  1014. angle?: number;
  1015. intensity?: number;
  1016. diffuse?: {
  1017. r: number;
  1018. g: number;
  1019. b: number;
  1020. };
  1021. specular?: {
  1022. r: number;
  1023. g: number;
  1024. b: number;
  1025. };
  1026. };
  1027. hideLoadingDelay?: number;
  1028. /** Deprecated */
  1029. assetsRootURL?: string;
  1030. environmentMainColor?: {
  1031. r: number;
  1032. g: number;
  1033. b: number;
  1034. };
  1035. /** Deprecated */
  1036. environmentMap?: {
  1037. /**
  1038. * Environment map texture path in relative to the asset folder.
  1039. */
  1040. texture: string;
  1041. /**
  1042. * Default rotation to apply to the environment map.
  1043. */
  1044. rotationY: number;
  1045. /**
  1046. * Tint level of the main color on the environment map.
  1047. */
  1048. tintLevel: number;
  1049. };
  1050. defaultRenderingPipelines?: boolean | IDefaultRenderingPipelineConfiguration;
  1051. globalLightRotation?: number;
  1052. };
  1053. }
  1054. }
  1055. declare module BabylonViewer {
  1056. /**
  1057. * The object sent when an event is triggered
  1058. */
  1059. export interface EventCallback {
  1060. event: Event;
  1061. template: Template;
  1062. selector: string;
  1063. payload?: any;
  1064. }
  1065. /**
  1066. * The template manager, a member of the viewer class, will manage the viewer's templates and generate the HTML.
  1067. * The template manager managers a single viewer and can be seen as the collection of all sub-templates of the viewer.
  1068. */
  1069. export class TemplateManager {
  1070. containerElement: Element;
  1071. /**
  1072. * Will be triggered when any template is initialized
  1073. */
  1074. onTemplateInit: BABYLON.Observable<Template>;
  1075. /**
  1076. * Will be triggered when any template is fully loaded
  1077. */
  1078. onTemplateLoaded: BABYLON.Observable<Template>;
  1079. /**
  1080. * Will be triggered when a template state changes
  1081. */
  1082. onTemplateStateChange: BABYLON.Observable<Template>;
  1083. /**
  1084. * Will be triggered when all templates finished loading
  1085. */
  1086. onAllLoaded: BABYLON.Observable<TemplateManager>;
  1087. /**
  1088. * Will be triggered when any event on any template is triggered.
  1089. */
  1090. onEventTriggered: BABYLON.Observable<EventCallback>;
  1091. /**
  1092. * This template manager's event manager. In charge of callback registrations to native event types
  1093. */
  1094. eventManager: EventManager;
  1095. constructor(containerElement: Element);
  1096. /**
  1097. * Initialize the template(s) for the viewer. Called bay the Viewer class
  1098. * @param templates the templates to be used to initialize the main template
  1099. */
  1100. initTemplate(templates: {
  1101. [key: string]: ITemplateConfiguration;
  1102. }): Promise<void>;
  1103. /**
  1104. * Get the canvas in the template tree.
  1105. * There must be one and only one canvas inthe template.
  1106. */
  1107. getCanvas(): HTMLCanvasElement | null;
  1108. /**
  1109. * Get a specific template from the template tree
  1110. * @param name the name of the template to load
  1111. */
  1112. getTemplate(name: string): Template | undefined;
  1113. /**
  1114. * Dispose the template manager
  1115. */
  1116. dispose(): void;
  1117. }
  1118. /**
  1119. * This class represents a single template in the viewer's template tree.
  1120. * An example for a template is a single canvas, an overlay (containing sub-templates) or the navigation bar.
  1121. * A template is injected using the template manager in the correct position.
  1122. * The template is rendered using Handlebars and can use Handlebars' features (such as parameter injection)
  1123. *
  1124. * For further information please refer to the documentation page, https://doc.babylonjs.com
  1125. */
  1126. export class Template {
  1127. name: string;
  1128. /**
  1129. * Will be triggered when the template is loaded
  1130. */
  1131. onLoaded: BABYLON.Observable<Template>;
  1132. /**
  1133. * will be triggered when the template is appended to the tree
  1134. */
  1135. onAppended: BABYLON.Observable<Template>;
  1136. /**
  1137. * Will be triggered when the template's state changed (shown, hidden)
  1138. */
  1139. onStateChange: BABYLON.Observable<Template>;
  1140. /**
  1141. * Will be triggered when an event is triggered on ths template.
  1142. * The event is a native browser event (like mouse or pointer events)
  1143. */
  1144. onEventTriggered: BABYLON.Observable<EventCallback>;
  1145. onParamsUpdated: BABYLON.Observable<Template>;
  1146. onHTMLRendered: BABYLON.Observable<Template>;
  1147. /**
  1148. * is the template loaded?
  1149. */
  1150. isLoaded: boolean;
  1151. /**
  1152. * This is meant to be used to track the show and hide functions.
  1153. * This is NOT (!!) a flag to check if the element is actually visible to the user.
  1154. */
  1155. isShown: boolean;
  1156. /**
  1157. * Is this template a part of the HTML tree (the template manager injected it)
  1158. */
  1159. isInHtmlTree: boolean;
  1160. /**
  1161. * The HTML element containing this template
  1162. */
  1163. parent: HTMLElement;
  1164. /**
  1165. * A promise that is fulfilled when the template finished loading.
  1166. */
  1167. initPromise: Promise<Template>;
  1168. constructor(name: string, _configuration: ITemplateConfiguration);
  1169. /**
  1170. * Some templates have parameters (like background color for example).
  1171. * The parameters are provided to Handlebars which in turn generates the template.
  1172. * This function will update the template with the new parameters
  1173. *
  1174. * Note that when updating parameters the events will be registered again (after being cleared).
  1175. *
  1176. * @param params the new template parameters
  1177. */
  1178. updateParams(params: {
  1179. [key: string]: string | number | boolean | object;
  1180. }, append?: boolean): void;
  1181. redraw(): void;
  1182. /**
  1183. * Get the template'S configuration
  1184. */
  1185. readonly configuration: ITemplateConfiguration;
  1186. /**
  1187. * A template can be a parent element for other templates or HTML elements.
  1188. * This function will deliver all child HTML elements of this template.
  1189. */
  1190. getChildElements(): Array<string>;
  1191. /**
  1192. * Appending the template to a parent HTML element.
  1193. * If a parent is already set and you wish to replace the old HTML with new one, forceRemove should be true.
  1194. * @param parent the parent to which the template is added
  1195. * @param forceRemove if the parent already exists, shoud the template be removed from it?
  1196. */
  1197. appendTo(parent: HTMLElement, forceRemove?: boolean): void;
  1198. /**
  1199. * Show the template using the provided visibilityFunction, or natively using display: flex.
  1200. * The provided function returns a promise that should be fullfilled when the element is shown.
  1201. * Since it is a promise async operations are more than possible.
  1202. * See the default viewer for an opacity example.
  1203. * @param visibilityFunction The function to execute to show the template.
  1204. */
  1205. show(visibilityFunction?: (template: Template) => Promise<Template>): Promise<Template>;
  1206. /**
  1207. * Hide the template using the provided visibilityFunction, or natively using display: none.
  1208. * The provided function returns a promise that should be fullfilled when the element is hidden.
  1209. * Since it is a promise async operations are more than possible.
  1210. * See the default viewer for an opacity example.
  1211. * @param visibilityFunction The function to execute to show the template.
  1212. */
  1213. hide(visibilityFunction?: (template: Template) => Promise<Template>): Promise<Template>;
  1214. /**
  1215. * Dispose this template
  1216. */
  1217. dispose(): void;
  1218. }
  1219. }
  1220. declare module BabylonViewer {
  1221. /**
  1222. * The AbstractViewer is the center of Babylon's viewer.
  1223. * It is the basic implementation of the default viewer and is responsible of loading and showing the model and the templates
  1224. */
  1225. export abstract class AbstractViewerWithTemplate extends AbstractViewer {
  1226. protected getConfigurationLoader(): ConfigurationLoader;
  1227. }
  1228. }
  1229. declare module BabylonViewer {
  1230. export class ConfigurationContainer {
  1231. configuration: ViewerConfiguration;
  1232. viewerId: string;
  1233. mainColor: BABYLON.Color3;
  1234. reflectionColor: BABYLON.Color3;
  1235. scene?: BABYLON.Scene;
  1236. }
  1237. }
  1238. declare module BabylonViewer {
  1239. /**
  1240. * The configuration loader will load the configuration object from any source and will use the defined mapper to
  1241. * parse the object and return a conform ViewerConfiguration.
  1242. * It is a private member of the scene.
  1243. */
  1244. export class RenderOnlyConfigurationLoader {
  1245. constructor(_enableCache?: boolean);
  1246. protected getExtendedConfig(type: string | undefined): ViewerConfiguration;
  1247. /**
  1248. * load a configuration object that is defined in the initial configuration provided.
  1249. * The viewer configuration can extend different types of configuration objects and have an extra configuration defined.
  1250. *
  1251. * @param initConfig the initial configuration that has the definitions of further configuration to load.
  1252. * @param callback an optional callback that will be called sync, if noconfiguration needs to be loaded or configuration is payload-only
  1253. * @returns A promise that delivers the extended viewer configuration, when done.
  1254. */
  1255. loadConfiguration(initConfig?: ViewerConfiguration, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration>;
  1256. /**
  1257. * Dispose the configuration loader. This will cancel file requests, if active.
  1258. */
  1259. dispose(): void;
  1260. }
  1261. }
  1262. declare module BabylonViewer {
  1263. export class ObservablesManager {
  1264. /**
  1265. * Will notify when the scene was initialized
  1266. */
  1267. onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
  1268. /**
  1269. * will notify when the engine was initialized
  1270. */
  1271. onEngineInitObservable: BABYLON.Observable<BABYLON.Engine>;
  1272. /**
  1273. * Will notify when a new model was added to the scene.
  1274. * Note that added does not neccessarily mean loaded!
  1275. */
  1276. onModelAddedObservable: BABYLON.Observable<ViewerModel>;
  1277. /**
  1278. * will notify after every model load
  1279. */
  1280. onModelLoadedObservable: BABYLON.Observable<ViewerModel>;
  1281. /**
  1282. * will notify when any model notify of progress
  1283. */
  1284. onModelLoadProgressObservable: BABYLON.Observable<BABYLON.SceneLoaderProgressEvent>;
  1285. /**
  1286. * will notify when any model load failed.
  1287. */
  1288. onModelLoadErrorObservable: BABYLON.Observable<{
  1289. message: string;
  1290. exception: any;
  1291. }>;
  1292. /**
  1293. * Will notify when a model was removed from the scene;
  1294. */
  1295. onModelRemovedObservable: BABYLON.Observable<ViewerModel>;
  1296. /**
  1297. * will notify when a new loader was initialized.
  1298. * Used mainly to know when a model starts loading.
  1299. */
  1300. onLoaderInitObservable: BABYLON.Observable<BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync>;
  1301. /**
  1302. * Observers registered here will be executed when the entire load process has finished.
  1303. */
  1304. onViewerInitDoneObservable: BABYLON.Observable<any>;
  1305. /**
  1306. * Will notify when the viewer init started (after configuration was loaded)
  1307. */
  1308. onViewerInitStartedObservable: BABYLON.Observable<any>;
  1309. /**
  1310. * Functions added to this observable will be executed on each frame rendered.
  1311. */
  1312. onFrameRenderedObservable: BABYLON.Observable<any>;
  1313. /**
  1314. * Will notify when VR mode is entered.
  1315. */
  1316. onEnteringVRObservable: BABYLON.Observable<any>;
  1317. /**
  1318. * Will notify when VR mode is exited.
  1319. */
  1320. onExitingVRObservable: BABYLON.Observable<any>;
  1321. constructor();
  1322. dispose(): void;
  1323. }
  1324. }
  1325. declare module BabylonViewer {
  1326. /**
  1327. * This interface describes the structure of the variable sent with the configuration observables of the scene manager.
  1328. * O - the type of object we are dealing with (Light, BABYLON.ArcRotateCamera, BABYLON.Scene, etc')
  1329. * T - the configuration type
  1330. */
  1331. export interface IPostConfigurationCallback<OBJ, CONF> {
  1332. newConfiguration: CONF;
  1333. sceneManager: SceneManager;
  1334. object: OBJ;
  1335. model?: ViewerModel;
  1336. }
  1337. export class SceneManager {
  1338. /**
  1339. * Will notify when the scene was initialized
  1340. */
  1341. onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
  1342. /**
  1343. * Will notify after the scene was configured. Can be used to further configure the scene
  1344. */
  1345. onSceneConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.Scene, ISceneConfiguration>>;
  1346. /**
  1347. * Will notify after the scene optimized was configured. Can be used to further configure the scene optimizer
  1348. */
  1349. onSceneOptimizerConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.SceneOptimizer, ISceneOptimizerConfiguration | boolean>>;
  1350. /**
  1351. * Will notify after the camera was configured. Can be used to further configure the camera
  1352. */
  1353. onCameraConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.ArcRotateCamera, ICameraConfiguration>>;
  1354. /**
  1355. * Will notify after the lights were configured. Can be used to further configure lights
  1356. */
  1357. onLightsConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<Array<BABYLON.Light>, {
  1358. [name: string]: ILightConfiguration | boolean | number;
  1359. }>>;
  1360. /**
  1361. * Will notify after the model(s) were configured. Can be used to further configure models
  1362. */
  1363. onModelsConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<Array<ViewerModel>, IModelConfiguration>>;
  1364. /**
  1365. * Will notify after the envirnoment was configured. Can be used to further configure the environment
  1366. */
  1367. onEnvironmentConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.EnvironmentHelper, {
  1368. skybox?: ISkyboxConfiguration | boolean;
  1369. ground?: IGroundConfiguration | boolean;
  1370. }>>;
  1371. /**
  1372. * Will notify after the model(s) were configured. Can be used to further configure models
  1373. */
  1374. onVRConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.VRExperienceHelper, IVRConfiguration>>;
  1375. /**
  1376. * The Babylon BABYLON.Scene of this viewer
  1377. */
  1378. scene: BABYLON.Scene;
  1379. /**
  1380. * The camera used in this viewer
  1381. */
  1382. camera: BABYLON.ArcRotateCamera;
  1383. /**
  1384. * Babylon's scene optimizer
  1385. */
  1386. sceneOptimizer: BABYLON.SceneOptimizer;
  1387. /**
  1388. * Models displayed in this viewer.
  1389. */
  1390. models: Array<ViewerModel>;
  1391. /**
  1392. * Babylon's environment helper of this viewer
  1393. */
  1394. environmentHelper?: BABYLON.EnvironmentHelper;
  1395. protected _defaultHighpTextureType: number;
  1396. protected _shadowGeneratorBias: number;
  1397. protected _defaultPipelineTextureType: number;
  1398. /**
  1399. * The maximum number of shadows supported by the curent viewer
  1400. */
  1401. protected _maxShadows: number;
  1402. /**
  1403. * The labs variable consists of objects that will have their API change.
  1404. * Please be careful when using labs in production.
  1405. */
  1406. labs: ViewerLabs;
  1407. readonly defaultRenderingPipeline: BABYLON.Nullable<BABYLON.DefaultRenderingPipeline>;
  1408. protected _vrHelper?: BABYLON.VRExperienceHelper;
  1409. readonly vrHelper: BABYLON.VRExperienceHelper | undefined;
  1410. constructor(_engine: BABYLON.Engine, _configurationContainer: ConfigurationContainer, _observablesManager?: ObservablesManager | undefined);
  1411. /**
  1412. * Returns a boolean representing HDR support
  1413. */
  1414. readonly isHdrSupported: boolean;
  1415. /**
  1416. * Return the main color defined in the configuration.
  1417. */
  1418. readonly mainColor: BABYLON.Color3;
  1419. readonly reflectionColor: BABYLON.Color3;
  1420. animationBlendingEnabled: boolean;
  1421. readonly observablesManager: ObservablesManager | undefined;
  1422. /**
  1423. * Should shadows be rendered every frame, or only once and stop.
  1424. * This can be used to optimize a scene.
  1425. *
  1426. * Not that the shadows will NOT disapear but will remain in place.
  1427. * @param process if true shadows will be updated once every frame. if false they will stop being updated.
  1428. */
  1429. processShadows: boolean;
  1430. groundEnabled: boolean;
  1431. /**
  1432. * sets wether the reflection is disabled.
  1433. */
  1434. groundMirrorEnabled: boolean;
  1435. defaultRenderingPipelineEnabled: boolean;
  1436. /**
  1437. * Sets the engine flags to unlock all babylon features.
  1438. * Can also be configured using the scene.flags configuration object
  1439. */
  1440. unlockBabylonFeatures(): void;
  1441. /**
  1442. * initialize the scene. Calling this function again will dispose the old scene, if exists.
  1443. */
  1444. initScene(sceneConfiguration?: ISceneConfiguration, optimizerConfiguration?: boolean | ISceneOptimizerConfiguration): Promise<BABYLON.Scene>;
  1445. clearScene(clearModels?: boolean, clearLights?: boolean): void;
  1446. /**
  1447. * This will update the scene's configuration, including camera, lights, environment.
  1448. * @param newConfiguration the delta that should be configured. This includes only the changes
  1449. * @param globalConfiguration The global configuration object, after the new configuration was merged into it
  1450. */
  1451. updateConfiguration(newConfiguration: Partial<ViewerConfiguration>): void;
  1452. bloomEnabled: boolean;
  1453. fxaaEnabled: boolean;
  1454. setDefaultMaterial(sceneConfig: ISceneConfiguration): void;
  1455. /**
  1456. * internally configure the scene using the provided configuration.
  1457. * The scene will not be recreated, but just updated.
  1458. * @param sceneConfig the (new) scene configuration
  1459. */
  1460. protected _configureScene(sceneConfig: ISceneConfiguration): void;
  1461. /**
  1462. * Configure the scene optimizer.
  1463. * The existing scene optimizer will be disposed and a new one will be created.
  1464. * @param optimizerConfig the (new) optimizer configuration
  1465. */
  1466. protected _configureOptimizer(optimizerConfig: ISceneOptimizerConfiguration | boolean): void;
  1467. /**
  1468. * configure all models using the configuration.
  1469. * @param modelConfiguration the configuration to use to reconfigure the models
  1470. */
  1471. protected _configureVR(vrConfig: IVRConfiguration): void;
  1472. protected _configureEnvironmentMap(environmentMapConfiguration: IEnvironmentMapConfiguration): any;
  1473. /**
  1474. * (Re) configure the camera. The camera will only be created once and from this point will only be reconfigured.
  1475. * @param cameraConfig the new camera configuration
  1476. * @param model optionally use the model to configure the camera.
  1477. */
  1478. protected _configureCamera(cameraConfig?: ICameraConfiguration): void;
  1479. protected _configureEnvironment(skyboxConifguration?: ISkyboxConfiguration | boolean, groundConfiguration?: IGroundConfiguration | boolean): void;
  1480. /**
  1481. * configure the lights.
  1482. *
  1483. * @param lightsConfiguration the (new) light(s) configuration
  1484. * @param model optionally use the model to configure the camera.
  1485. */
  1486. protected _configureLights(lightsConfiguration?: {
  1487. [name: string]: ILightConfiguration | boolean | number;
  1488. }): void;
  1489. /**
  1490. * Gets the shadow map blur kernel according to the light configuration.
  1491. * @param light The light used to generate the shadows
  1492. * @param bufferSize The size of the shadow map
  1493. * @return the kernel blur size
  1494. */
  1495. getBlurKernel(light: BABYLON.IShadowLight, bufferSize: number): number;
  1496. /**
  1497. * Alters render settings to reduce features based on hardware feature limitations
  1498. * @param enableHDR Allows the viewer to run in HDR mode.
  1499. */
  1500. protected _handleHardwareLimitations(enableHDR?: boolean): void;
  1501. /**
  1502. * Dispoe the entire viewer including the scene and the engine
  1503. */
  1504. dispose(): void;
  1505. }
  1506. }
  1507. declare module BabylonViewer {
  1508. export interface IModelConfiguration {
  1509. id?: string;
  1510. url?: string;
  1511. root?: string;
  1512. file?: string | File;
  1513. loader?: string;
  1514. position?: {
  1515. x: number;
  1516. y: number;
  1517. z: number;
  1518. };
  1519. rotation?: {
  1520. x: number;
  1521. y: number;
  1522. z: number;
  1523. w?: number;
  1524. };
  1525. scaling?: {
  1526. x: number;
  1527. y: number;
  1528. z: number;
  1529. };
  1530. parentObjectIndex?: number;
  1531. castShadow?: boolean;
  1532. receiveShadows?: boolean;
  1533. normalize?: boolean | {
  1534. center?: boolean;
  1535. unitSize?: boolean;
  1536. parentIndex?: number;
  1537. };
  1538. title?: string;
  1539. subtitle?: string;
  1540. thumbnail?: string;
  1541. animation?: {
  1542. autoStart?: boolean | string;
  1543. playOnce?: boolean;
  1544. autoStartIndex?: number;
  1545. };
  1546. entryAnimation?: IModelAnimationConfiguration;
  1547. exitAnimation?: IModelAnimationConfiguration;
  1548. material?: {
  1549. directEnabled?: boolean;
  1550. directIntensity?: number;
  1551. emissiveIntensity?: number;
  1552. environmentIntensity?: number;
  1553. [propName: string]: any;
  1554. };
  1555. /**
  1556. * Rotation offset axis definition
  1557. */
  1558. rotationOffsetAxis?: {
  1559. x: number;
  1560. y: number;
  1561. z: number;
  1562. };
  1563. /**
  1564. * the offset angle
  1565. */
  1566. rotationOffsetAngle?: number;
  1567. loaderConfiguration?: {
  1568. maxLODsToLoad?: number;
  1569. progressiveLoading?: boolean;
  1570. };
  1571. }
  1572. }
  1573. declare module BabylonViewer {
  1574. /**
  1575. * Get a loader plugin according to its name.
  1576. * The plugin will be cached and will be reused if called for again.
  1577. *
  1578. * @param name the name of the plugin
  1579. */
  1580. export function getLoaderPluginByName(name: string): ILoaderPlugin;
  1581. /**
  1582. *
  1583. */
  1584. export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
  1585. }
  1586. declare module BabylonViewer {
  1587. export interface IEnvironmentMapConfiguration {
  1588. /**
  1589. * Environment map texture path in relative to the asset folder.
  1590. */
  1591. texture: string;
  1592. /**
  1593. * Default rotation to apply to the environment map.
  1594. */
  1595. rotationY: number;
  1596. /**
  1597. * Tint level of the main color on the environment map.
  1598. */
  1599. tintLevel: number;
  1600. /**
  1601. * The environment's main color.
  1602. */
  1603. mainColor?: {
  1604. r?: number;
  1605. g?: number;
  1606. b?: number;
  1607. };
  1608. }
  1609. }
  1610. declare module BabylonViewer {
  1611. /**
  1612. * The EventManager is in charge of registering user interctions with the viewer.
  1613. * It is used in the TemplateManager
  1614. */
  1615. export class EventManager {
  1616. constructor(_templateManager: TemplateManager);
  1617. /**
  1618. * Register a new callback to a specific template.
  1619. * The best example for the usage can be found in the DefaultViewer
  1620. *
  1621. * @param templateName the templateName to register the event to
  1622. * @param callback The callback to be executed
  1623. * @param eventType the type of event to register
  1624. * @param selector an optional selector. if not defined the parent object in the template will be selected
  1625. */
  1626. registerCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
  1627. /**
  1628. * This will remove a registered event from the defined template.
  1629. * Each one of the variables apart from the template name are optional, but one must be provided.
  1630. *
  1631. * @param templateName the templateName
  1632. * @param callback the callback to remove (optional)
  1633. * @param eventType the event type to remove (optional)
  1634. * @param selector the selector from which to remove the event (optional)
  1635. */
  1636. unregisterCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
  1637. /**
  1638. * Dispose the event manager
  1639. */
  1640. dispose(): void;
  1641. }
  1642. }
  1643. declare module BabylonViewer {
  1644. export class ConfigurationLoader extends RenderOnlyConfigurationLoader {
  1645. protected getExtendedConfig(type: string | undefined): import("./configuration").ViewerConfiguration;
  1646. }
  1647. }
  1648. declare module BabylonViewer {
  1649. /**
  1650. * The ViewerLabs class will hold functions that are not (!) backwards compatible.
  1651. * The APIs in all labs-related classes and configuration might change.
  1652. * Once stable, lab features will be moved to the publis API and configuration object.
  1653. */
  1654. export class ViewerLabs {
  1655. constructor(_scene: BABYLON.Scene);
  1656. assetsRootURL: string;
  1657. environment: PBREnvironment;
  1658. /**
  1659. * Loads an environment map from a given URL
  1660. * @param url URL of environment map
  1661. * @param onSuccess Callback fired after environment successfully applied to the scene
  1662. * @param onProgress Callback fired at progress events while loading the environment map
  1663. * @param onError Callback fired when the load fails
  1664. */
  1665. loadEnvironment(url: string, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
  1666. /**
  1667. * Loads an environment map from a given URL
  1668. * @param buffer ArrayBuffer containing environment map
  1669. * @param onSuccess Callback fired after environment successfully applied to the scene
  1670. * @param onProgress Callback fired at progress events while loading the environment map
  1671. * @param onError Callback fired when the load fails
  1672. */
  1673. loadEnvironment(buffer: ArrayBuffer, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
  1674. /**
  1675. * Sets the environment to an already loaded environment
  1676. * @param env PBREnvironment instance
  1677. * @param onSuccess Callback fired after environment successfully applied to the scene
  1678. * @param onProgress Callback fired at progress events while loading the environment map
  1679. * @param onError Callback fired when the load fails
  1680. */
  1681. loadEnvironment(env: PBREnvironment, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
  1682. /**
  1683. * Applies an `EnvironmentMapConfiguration` to the scene
  1684. * @param environmentMapConfiguration Environment map configuration to apply
  1685. */
  1686. applyEnvironmentMapConfiguration(rotationY?: number): void;
  1687. /**
  1688. * Get an environment asset url by using the configuration if the path is not absolute.
  1689. * @param url Asset url
  1690. * @returns The Asset url using the `environmentAssetsRootURL` if the url is not an absolute path.
  1691. */
  1692. getAssetUrl(url: string): string;
  1693. rotateShadowLight(shadowLight: BABYLON.ShadowLight, amount: number, point?: BABYLON.Vector3, axis?: BABYLON.Vector3, target?: BABYLON.Vector3): void;
  1694. }
  1695. }
  1696. declare module BabylonViewer {
  1697. /**
  1698. * Defines an animation to be applied to a model (translation, scale or rotation).
  1699. */
  1700. export interface IModelAnimationConfiguration {
  1701. /**
  1702. * Time of animation, in seconds
  1703. */
  1704. time?: number;
  1705. /**
  1706. * Scale to apply
  1707. */
  1708. scaling?: {
  1709. x: number;
  1710. y: number;
  1711. z: number;
  1712. };
  1713. /**
  1714. * Easing function to apply
  1715. */
  1716. easingFunction?: number;
  1717. /**
  1718. * An Easing mode to apply to the easing function
  1719. * See BABYLON.EasingFunction
  1720. */
  1721. easingMode?: number;
  1722. }
  1723. }
  1724. declare module BabylonViewer {
  1725. export class TelemetryLoaderPlugin implements ILoaderPlugin {
  1726. onInit(loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel): void;
  1727. onLoaded(model: ViewerModel): void;
  1728. onError(message: string, exception: any): void;
  1729. onComplete(): void;
  1730. }
  1731. }
  1732. declare module BabylonViewer {
  1733. /**
  1734. * A loder plugin to use MSFT_lod extension correctly (glTF)
  1735. */
  1736. export class MSFTLodLoaderPlugin implements ILoaderPlugin {
  1737. onInit(loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel): void;
  1738. onExtensionLoaded(extension: BABYLON.IGLTFLoaderExtension): void;
  1739. }
  1740. }
  1741. declare module BabylonViewer {
  1742. /**
  1743. * Force-apply material configuration right after a material was loaded.
  1744. */
  1745. export class ApplyMaterialConfigPlugin implements ILoaderPlugin {
  1746. onInit(loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel): void;
  1747. onMaterialLoaded(material: BABYLON.Material): void;
  1748. }
  1749. }
  1750. declare module BabylonViewer {
  1751. /**
  1752. * A (PBR) material will be extended using this function.
  1753. * This function will hold extra default configuration for the viewer, if not implemented in Babylon itself.
  1754. */
  1755. export class ExtendedMaterialLoaderPlugin implements ILoaderPlugin {
  1756. onMaterialLoaded(baseMaterial: BABYLON.Material): void;
  1757. }
  1758. }
  1759. declare module BabylonViewer {
  1760. export interface ICameraConfiguration {
  1761. position?: {
  1762. x: number;
  1763. y: number;
  1764. z: number;
  1765. };
  1766. rotation?: {
  1767. x: number;
  1768. y: number;
  1769. z: number;
  1770. w: number;
  1771. };
  1772. fov?: number;
  1773. fovMode?: number;
  1774. minZ?: number;
  1775. maxZ?: number;
  1776. inertia?: number;
  1777. exposure?: number;
  1778. pinchPrecision?: number;
  1779. behaviors?: {
  1780. [name: string]: boolean | number | ICameraBehaviorConfiguration;
  1781. };
  1782. disableCameraControl?: boolean;
  1783. disableCtrlForPanning?: boolean;
  1784. disableAutoFocus?: boolean;
  1785. [propName: string]: any;
  1786. }
  1787. export interface ICameraBehaviorConfiguration {
  1788. type: number;
  1789. [propName: string]: any;
  1790. }
  1791. }
  1792. declare module BabylonViewer {
  1793. /**
  1794. * The Color Grading Configuration groups the different settings used to define the color grading used in the viewer.
  1795. */
  1796. export interface IColorGradingConfiguration {
  1797. /**
  1798. * Transform data string, encoded as determined by transformDataFormat.
  1799. */
  1800. transformData: string;
  1801. /**
  1802. * The encoding format of TransformData (currently only raw-base16 is supported).
  1803. */
  1804. transformDataFormat: string;
  1805. /**
  1806. * The weight of the transform
  1807. */
  1808. transformWeight: number;
  1809. /**
  1810. * Color curve colorFilterHueGlobal value
  1811. */
  1812. colorFilterHueGlobal: number;
  1813. /**
  1814. * Color curve colorFilterHueShadows value
  1815. */
  1816. colorFilterHueShadows: number;
  1817. /**
  1818. * Color curve colorFilterHueMidtones value
  1819. */
  1820. colorFilterHueMidtones: number;
  1821. /**
  1822. * Color curve colorFilterHueHighlights value
  1823. */
  1824. colorFilterHueHighlights: number;
  1825. /**
  1826. * Color curve colorFilterDensityGlobal value
  1827. */
  1828. colorFilterDensityGlobal: number;
  1829. /**
  1830. * Color curve colorFilterDensityShadows value
  1831. */
  1832. colorFilterDensityShadows: number;
  1833. /**
  1834. * Color curve colorFilterDensityMidtones value
  1835. */
  1836. colorFilterDensityMidtones: number;
  1837. /**
  1838. * Color curve colorFilterDensityHighlights value
  1839. */
  1840. colorFilterDensityHighlights: number;
  1841. /**
  1842. * Color curve saturationGlobal value
  1843. */
  1844. saturationGlobal: number;
  1845. /**
  1846. * Color curve saturationShadows value
  1847. */
  1848. saturationShadows: number;
  1849. /**
  1850. * Color curve saturationMidtones value
  1851. */
  1852. saturationMidtones: number;
  1853. /**
  1854. * Color curve saturationHighlights value
  1855. */
  1856. saturationHighlights: number;
  1857. /**
  1858. * Color curve exposureGlobal value
  1859. */
  1860. exposureGlobal: number;
  1861. /**
  1862. * Color curve exposureShadows value
  1863. */
  1864. exposureShadows: number;
  1865. /**
  1866. * Color curve exposureMidtones value
  1867. */
  1868. exposureMidtones: number;
  1869. /**
  1870. * Color curve exposureHighlights value
  1871. */
  1872. exposureHighlights: number;
  1873. }
  1874. }
  1875. declare module BabylonViewer {
  1876. export interface IDefaultRenderingPipelineConfiguration {
  1877. sharpenEnabled?: boolean;
  1878. bloomEnabled?: boolean;
  1879. bloomThreshold?: number;
  1880. depthOfFieldEnabled?: boolean;
  1881. depthOfFieldBlurLevel?: BABYLON.DepthOfFieldEffectBlurLevel;
  1882. fxaaEnabled?: boolean;
  1883. imageProcessingEnabled?: boolean;
  1884. defaultPipelineTextureType?: number;
  1885. bloomScale?: number;
  1886. chromaticAberrationEnabled?: boolean;
  1887. grainEnabled?: boolean;
  1888. bloomKernel?: number;
  1889. hardwareScaleLevel?: number;
  1890. bloomWeight?: number;
  1891. hdr?: boolean;
  1892. samples?: number;
  1893. glowLayerEnabled?: boolean;
  1894. }
  1895. }
  1896. declare module BabylonViewer {
  1897. export interface IGroundConfiguration {
  1898. size?: number;
  1899. receiveShadows?: boolean;
  1900. shadowLevel?: number;
  1901. shadowOnly?: boolean;
  1902. mirror?: boolean | {
  1903. sizeRatio?: number;
  1904. blurKernel?: number;
  1905. amount?: number;
  1906. fresnelWeight?: number;
  1907. fallOffDistance?: number;
  1908. textureType?: number;
  1909. };
  1910. texture?: string;
  1911. color?: {
  1912. r: number;
  1913. g: number;
  1914. b: number;
  1915. };
  1916. opacity?: number;
  1917. material?: {
  1918. [propName: string]: any;
  1919. };
  1920. }
  1921. }
  1922. declare module BabylonViewer {
  1923. export interface IImageProcessingConfiguration {
  1924. colorGradingEnabled?: boolean;
  1925. colorCurvesEnabled?: boolean;
  1926. colorCurves?: {
  1927. globalHue?: number;
  1928. globalDensity?: number;
  1929. globalSaturation?: number;
  1930. globalExposure?: number;
  1931. highlightsHue?: number;
  1932. highlightsDensity?: number;
  1933. highlightsSaturation?: number;
  1934. highlightsExposure?: number;
  1935. midtonesHue?: number;
  1936. midtonesDensity?: number;
  1937. midtonesSaturation?: number;
  1938. midtonesExposure?: number;
  1939. shadowsHue?: number;
  1940. shadowsDensity?: number;
  1941. shadowsSaturation?: number;
  1942. shadowsExposure?: number;
  1943. };
  1944. colorGradingWithGreenDepth?: boolean;
  1945. colorGradingBGR?: boolean;
  1946. exposure?: number;
  1947. toneMappingEnabled?: boolean;
  1948. contrast?: number;
  1949. vignetteEnabled?: boolean;
  1950. vignetteStretch?: number;
  1951. vignetteCentreX?: number;
  1952. vignetteCentreY?: number;
  1953. vignetteWeight?: number;
  1954. vignetteColor?: {
  1955. r: number;
  1956. g: number;
  1957. b: number;
  1958. a?: number;
  1959. };
  1960. vignetteCameraFov?: number;
  1961. vignetteBlendMode?: number;
  1962. vignetteM?: boolean;
  1963. applyByPostProcess?: boolean;
  1964. isEnabled?: boolean;
  1965. }
  1966. }
  1967. declare module BabylonViewer {
  1968. export interface ILightConfiguration {
  1969. type: number;
  1970. name?: string;
  1971. disabled?: boolean;
  1972. position?: {
  1973. x: number;
  1974. y: number;
  1975. z: number;
  1976. };
  1977. target?: {
  1978. x: number;
  1979. y: number;
  1980. z: number;
  1981. };
  1982. direction?: {
  1983. x: number;
  1984. y: number;
  1985. z: number;
  1986. };
  1987. diffuse?: {
  1988. r: number;
  1989. g: number;
  1990. b: number;
  1991. };
  1992. specular?: {
  1993. r: number;
  1994. g: number;
  1995. b: number;
  1996. };
  1997. intensity?: number;
  1998. intensityMode?: number;
  1999. radius?: number;
  2000. shadownEnabled?: boolean;
  2001. shadowConfig?: {
  2002. useBlurExponentialShadowMap?: boolean;
  2003. useBlurCloseExponentialShadowMap?: boolean;
  2004. useKernelBlur?: boolean;
  2005. blurKernel?: number;
  2006. blurScale?: number;
  2007. minZ?: number;
  2008. maxZ?: number;
  2009. frustumSize?: number;
  2010. angleScale?: number;
  2011. frustumEdgeFalloff?: number;
  2012. [propName: string]: any;
  2013. };
  2014. spotAngle?: number;
  2015. shadowFieldOfView?: number;
  2016. shadowBufferSize?: number;
  2017. shadowFrustumSize?: number;
  2018. shadowMinZ?: number;
  2019. shadowMaxZ?: number;
  2020. [propName: string]: any;
  2021. behaviors?: {
  2022. [name: string]: number | {
  2023. type: number;
  2024. [propName: string]: any;
  2025. };
  2026. };
  2027. }
  2028. }
  2029. declare module BabylonViewer {
  2030. export interface IObserversConfiguration {
  2031. onEngineInit?: string;
  2032. onSceneInit?: string;
  2033. onModelLoaded?: string;
  2034. }
  2035. }
  2036. declare module BabylonViewer {
  2037. export interface ISceneConfiguration {
  2038. debug?: boolean;
  2039. clearColor?: {
  2040. r: number;
  2041. g: number;
  2042. b: number;
  2043. a: number;
  2044. };
  2045. /** Deprecated, use environmentMap.mainColor instead. */
  2046. mainColor?: {
  2047. r?: number;
  2048. g?: number;
  2049. b?: number;
  2050. };
  2051. imageProcessingConfiguration?: IImageProcessingConfiguration;
  2052. environmentTexture?: string;
  2053. colorGrading?: IColorGradingConfiguration;
  2054. environmentRotationY?: number;
  2055. /**
  2056. * Deprecated, please use default rendering pipeline
  2057. */
  2058. glow?: boolean | BABYLON.IGlowLayerOptions;
  2059. disableHdr?: boolean;
  2060. renderInBackground?: boolean;
  2061. disableCameraControl?: boolean;
  2062. animationPropertiesOverride?: {
  2063. [propName: string]: any;
  2064. };
  2065. defaultMaterial?: {
  2066. materialType: "standard" | "pbr";
  2067. [propName: string]: any;
  2068. };
  2069. flags?: {
  2070. shadowsEnabled?: boolean;
  2071. particlesEnabled?: boolean;
  2072. collisionsEnabled?: boolean;
  2073. lightsEnabled?: boolean;
  2074. texturesEnabled?: boolean;
  2075. lensFlaresEnabled?: boolean;
  2076. proceduralTexturesEnabled?: boolean;
  2077. renderTargetsEnabled?: boolean;
  2078. spritesEnabled?: boolean;
  2079. skeletonsEnabled?: boolean;
  2080. audioEnabled?: boolean;
  2081. };
  2082. assetsRootURL?: string;
  2083. }
  2084. }
  2085. declare module BabylonViewer {
  2086. export interface ISceneOptimizerConfiguration {
  2087. targetFrameRate?: number;
  2088. trackerDuration?: number;
  2089. autoGeneratePriorities?: boolean;
  2090. improvementMode?: boolean;
  2091. degradation?: string;
  2092. types?: {
  2093. texture?: ISceneOptimizerParameters;
  2094. hardwareScaling?: ISceneOptimizerParameters;
  2095. shadow?: ISceneOptimizerParameters;
  2096. postProcess?: ISceneOptimizerParameters;
  2097. lensFlare?: ISceneOptimizerParameters;
  2098. particles?: ISceneOptimizerParameters;
  2099. renderTarget?: ISceneOptimizerParameters;
  2100. mergeMeshes?: ISceneOptimizerParameters;
  2101. };
  2102. custom?: string;
  2103. }
  2104. export interface ISceneOptimizerParameters {
  2105. priority?: number;
  2106. maximumSize?: number;
  2107. step?: number;
  2108. }
  2109. }
  2110. declare module BabylonViewer {
  2111. export interface ISkyboxConfiguration {
  2112. cubeTexture?: {
  2113. noMipMap?: boolean;
  2114. gammaSpace?: boolean;
  2115. url?: string | Array<string>;
  2116. };
  2117. color?: {
  2118. r: number;
  2119. g: number;
  2120. b: number;
  2121. };
  2122. pbr?: boolean;
  2123. scale?: number;
  2124. blur?: number;
  2125. material?: {
  2126. imageProcessingConfiguration?: IImageProcessingConfiguration;
  2127. [propName: string]: any;
  2128. };
  2129. infiniteDistance?: boolean;
  2130. }
  2131. }
  2132. declare module BabylonViewer {
  2133. /**
  2134. * A single template configuration object
  2135. */
  2136. export interface ITemplateConfiguration {
  2137. /**
  2138. * can be either the id of the template's html element or a URL.
  2139. * See - http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
  2140. */
  2141. location?: string;
  2142. /**
  2143. * If no location is provided you can provide here the raw html of this template.
  2144. * See http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
  2145. */
  2146. html?: string;
  2147. id?: string;
  2148. /**
  2149. * Parameters that will be delivered to the template and will render it accordingly.
  2150. */
  2151. params?: {
  2152. [key: string]: string | number | boolean | object;
  2153. };
  2154. /**
  2155. * Events to attach to this template.
  2156. * event name is the key. the value can either be a boolean (attach to the parent element)
  2157. * or a map of html id elements.
  2158. *
  2159. * See - http://doc.babylonjs.com/extensions/the_templating_system#event-binding
  2160. */
  2161. events?: {
  2162. pointerdown?: boolean | {
  2163. [id: string]: boolean;
  2164. };
  2165. pointerup?: boolean | {
  2166. [id: string]: boolean;
  2167. };
  2168. pointermove?: boolean | {
  2169. [id: string]: boolean;
  2170. };
  2171. pointerover?: boolean | {
  2172. [id: string]: boolean;
  2173. };
  2174. pointerout?: boolean | {
  2175. [id: string]: boolean;
  2176. };
  2177. pointerenter?: boolean | {
  2178. [id: string]: boolean;
  2179. };
  2180. pointerleave?: boolean | {
  2181. [id: string]: boolean;
  2182. };
  2183. pointercancel?: boolean | {
  2184. [id: string]: boolean;
  2185. };
  2186. click?: boolean | {
  2187. [id: string]: boolean;
  2188. };
  2189. dragstart?: boolean | {
  2190. [id: string]: boolean;
  2191. };
  2192. drop?: boolean | {
  2193. [id: string]: boolean;
  2194. };
  2195. [key: string]: boolean | {
  2196. [id: string]: boolean;
  2197. } | undefined;
  2198. };
  2199. }
  2200. }
  2201. declare module BabylonViewer {
  2202. export interface IVRConfiguration {
  2203. disabled?: boolean;
  2204. objectScaleFactor?: number;
  2205. disableInteractions?: boolean;
  2206. disableTeleportation?: boolean;
  2207. overrideFloorMeshName?: string;
  2208. vrOptions?: BABYLON.VRExperienceHelperOptions;
  2209. modelHeightCorrection?: number | boolean;
  2210. rotateUsingControllers?: boolean;
  2211. cameraPosition?: {
  2212. x: number;
  2213. y: number;
  2214. z: number;
  2215. };
  2216. }
  2217. }
  2218. declare module BabylonViewer {
  2219. /**
  2220. * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)
  2221. * @ignoreChildren
  2222. */
  2223. export interface SphericalPolynomalCoefficients {
  2224. x: BABYLON.Vector3;
  2225. y: BABYLON.Vector3;
  2226. z: BABYLON.Vector3;
  2227. xx: BABYLON.Vector3;
  2228. yy: BABYLON.Vector3;
  2229. zz: BABYLON.Vector3;
  2230. yz: BABYLON.Vector3;
  2231. zx: BABYLON.Vector3;
  2232. xy: BABYLON.Vector3;
  2233. }
  2234. /**
  2235. * Wraps data and maps required for environments with physically based rendering
  2236. */
  2237. export interface PBREnvironment {
  2238. /**
  2239. * Spherical Polynomial Coefficients representing an irradiance map
  2240. */
  2241. irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;
  2242. /**
  2243. * Specular cubemap
  2244. */
  2245. specularTexture?: TextureCube;
  2246. /**
  2247. * A scale factor applied to RGB values after reading from environment maps
  2248. */
  2249. textureIntensityScale: number;
  2250. }
  2251. /**
  2252. * Environment map representations: layouts, projections and approximations
  2253. */
  2254. export type MapType = 'irradiance_sh_coefficients_9' | 'cubemap_faces';
  2255. /**
  2256. * Image type used for environment map
  2257. */
  2258. export type ImageType = 'png';
  2259. /**
  2260. * A generic field in JSON that report's its type
  2261. */
  2262. export interface TypedObject<T> {
  2263. type: T;
  2264. }
  2265. /**
  2266. * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1
  2267. */
  2268. export interface ByteRange {
  2269. pos: number;
  2270. length: number;
  2271. }
  2272. /**
  2273. * Complete Spectre Environment JSON Descriptor
  2274. */
  2275. export interface EnvJsonDescriptor {
  2276. radiance: TypedObject<MapType>;
  2277. irradiance: TypedObject<MapType>;
  2278. specular: TypedObject<MapType>;
  2279. }
  2280. /**
  2281. * Spherical harmonic coefficients to provide an irradiance map
  2282. */
  2283. export interface IrradianceSHCoefficients9 extends TypedObject<MapType> {
  2284. l00: Array<number>;
  2285. l1_1: Array<number>;
  2286. l10: Array<number>;
  2287. l11: Array<number>;
  2288. l2_2: Array<number>;
  2289. l2_1: Array<number>;
  2290. l20: Array<number>;
  2291. l21: Array<number>;
  2292. l22: Array<number>;
  2293. }
  2294. /**
  2295. * A generic set of images, where the image content is specified by byte ranges in the mipmaps field
  2296. */
  2297. export interface ImageSet<T> extends TypedObject<MapType> {
  2298. imageType: ImageType;
  2299. width: number;
  2300. height: number;
  2301. mipmaps: Array<T>;
  2302. multiplier: number;
  2303. }
  2304. /**
  2305. * A set of cubemap faces
  2306. */
  2307. export type CubemapFaces = ImageSet<Array<ByteRange>>;
  2308. /**
  2309. * A single image containing an atlas of equirectangular-projection maps across all mip levels
  2310. */
  2311. export type EquirectangularMipmapAtlas = ImageSet<ByteRange>;
  2312. /**
  2313. * A static class proving methods to aid parsing Spectre environment files
  2314. */
  2315. export class EnvironmentDeserializer {
  2316. /**
  2317. * Parses an arraybuffer into a new PBREnvironment object
  2318. * @param arrayBuffer The arraybuffer of the Spectre environment file
  2319. * @return a PBREnvironment object
  2320. */
  2321. static Parse(arrayBuffer: ArrayBuffer): PBREnvironment;
  2322. }
  2323. }
  2324. declare module BabylonViewer {
  2325. /**
  2326. * WebGL Pixel Formats
  2327. */
  2328. export const enum PixelFormat {
  2329. DEPTH_COMPONENT = 6402,
  2330. ALPHA = 6406,
  2331. RGB = 6407,
  2332. RGBA = 6408,
  2333. LUMINANCE = 6409,
  2334. LUMINANCE_ALPHA = 6410
  2335. }
  2336. /**
  2337. * WebGL Pixel Types
  2338. */
  2339. export const enum PixelType {
  2340. UNSIGNED_BYTE = 5121,
  2341. UNSIGNED_SHORT_4_4_4_4 = 32819,
  2342. UNSIGNED_SHORT_5_5_5_1 = 32820,
  2343. UNSIGNED_SHORT_5_6_5 = 33635
  2344. }
  2345. /**
  2346. * WebGL Texture Magnification Filter
  2347. */
  2348. export const enum TextureMagFilter {
  2349. NEAREST = 9728,
  2350. LINEAR = 9729
  2351. }
  2352. /**
  2353. * WebGL Texture Minification Filter
  2354. */
  2355. export const enum TextureMinFilter {
  2356. NEAREST = 9728,
  2357. LINEAR = 9729,
  2358. NEAREST_MIPMAP_NEAREST = 9984,
  2359. LINEAR_MIPMAP_NEAREST = 9985,
  2360. NEAREST_MIPMAP_LINEAR = 9986,
  2361. LINEAR_MIPMAP_LINEAR = 9987
  2362. }
  2363. /**
  2364. * WebGL Texture Wrap Modes
  2365. */
  2366. export const enum TextureWrapMode {
  2367. REPEAT = 10497,
  2368. CLAMP_TO_EDGE = 33071,
  2369. MIRRORED_REPEAT = 33648
  2370. }
  2371. /**
  2372. * Raw texture data and descriptor sufficient for WebGL texture upload
  2373. */
  2374. export interface TextureData {
  2375. /**
  2376. * Width of image
  2377. */
  2378. width: number;
  2379. /**
  2380. * Height of image
  2381. */
  2382. height: number;
  2383. /**
  2384. * Format of pixels in data
  2385. */
  2386. format: PixelFormat;
  2387. /**
  2388. * Row byte alignment of pixels in data
  2389. */
  2390. alignment: number;
  2391. /**
  2392. * Pixel data
  2393. */
  2394. data: ArrayBufferView;
  2395. }
  2396. /**
  2397. * Wraps sampling parameters for a WebGL texture
  2398. */
  2399. export interface SamplingParameters {
  2400. /**
  2401. * Magnification mode when upsampling from a WebGL texture
  2402. */
  2403. magFilter?: TextureMagFilter;
  2404. /**
  2405. * Minification mode when upsampling from a WebGL texture
  2406. */
  2407. minFilter?: TextureMinFilter;
  2408. /**
  2409. * X axis wrapping mode when sampling out of a WebGL texture bounds
  2410. */
  2411. wrapS?: TextureWrapMode;
  2412. /**
  2413. * Y axis wrapping mode when sampling out of a WebGL texture bounds
  2414. */
  2415. wrapT?: TextureWrapMode;
  2416. /**
  2417. * Anisotropic filtering samples
  2418. */
  2419. maxAnisotropy?: number;
  2420. }
  2421. /**
  2422. * Represents a valid WebGL texture source for use in texImage2D
  2423. */
  2424. export type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;
  2425. /**
  2426. * A generic set of texture mipmaps (where index 0 has the largest dimension)
  2427. */
  2428. export type Mipmaps<T> = Array<T>;
  2429. /**
  2430. * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]
  2431. */
  2432. export type Faces<T> = Array<T>;
  2433. /**
  2434. * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)
  2435. */
  2436. export type Mipmaps2D = Mipmaps<TextureSource>;
  2437. /**
  2438. * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)
  2439. */
  2440. export type MipmapsCube = Mipmaps<Faces<TextureSource>>;
  2441. /**
  2442. * A minimal WebGL cubemap descriptor
  2443. */
  2444. export class TextureCube {
  2445. internalFormat: PixelFormat;
  2446. type: PixelType;
  2447. source: MipmapsCube;
  2448. /**
  2449. * Returns the width of a face of the texture or 0 if not available
  2450. */
  2451. readonly Width: number;
  2452. /**
  2453. * Returns the height of a face of the texture or 0 if not available
  2454. */
  2455. readonly Height: number;
  2456. /**
  2457. * constructor
  2458. * @param internalFormat WebGL pixel format for the texture on the GPU
  2459. * @param type WebGL pixel type of the supplied data and texture on the GPU
  2460. * @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
  2461. */
  2462. constructor(internalFormat: PixelFormat, type: PixelType, source?: MipmapsCube);
  2463. }
  2464. /**
  2465. * A static class providing methods to aid working with Bablyon textures.
  2466. */
  2467. export class TextureUtils {
  2468. /**
  2469. * A prefix used when storing a babylon texture object reference on a Spectre texture object
  2470. */
  2471. static BabylonTextureKeyPrefix: string;
  2472. /**
  2473. * Controls anisotropic filtering for deserialized textures.
  2474. */
  2475. static MaxAnisotropy: number;
  2476. /**
  2477. * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.
  2478. * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.
  2479. * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.
  2480. * @param scene A Babylon BABYLON.Scene instance
  2481. * @param textureCube A Spectre TextureCube object
  2482. * @param parameters WebGL texture sampling parameters
  2483. * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)
  2484. * @param environment Specifies that the texture will be used as an environment
  2485. * @param singleLod Specifies that the texture will be a singleLod (for environment)
  2486. * @return Babylon cube texture
  2487. */
  2488. static GetBabylonCubeTexture(scene: BABYLON.Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment?: boolean, singleLod?: boolean): BABYLON.CubeTexture;
  2489. /**
  2490. * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields
  2491. * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)
  2492. * @param parameters Spectre SamplingParameters to apply
  2493. */
  2494. static ApplySamplingParameters(babylonTexture: BABYLON.BaseTexture, parameters: SamplingParameters): void;
  2495. /**
  2496. * Environment preprocessing dedicated value (Internal Use or Advanced only).
  2497. */
  2498. static EnvironmentLODScale: number;
  2499. /**
  2500. * Environment preprocessing dedicated value (Internal Use or Advanced only)..
  2501. */
  2502. static EnvironmentLODOffset: number;
  2503. }
  2504. }