babylon.viewer.module.d.ts 117 KB

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