babylon.viewer.module.d.ts 114 KB

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