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