babylon.viewer.module.d.ts 112 KB

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