babylon.viewer.module.d.ts 118 KB

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