babylon.viewer.module.d.ts 119 KB

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