babylon.viewer.module.d.ts 119 KB

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