babylon.viewer.module.d.ts 119 KB

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