babylon.viewer.module.d.ts 118 KB

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