babylon.viewer.module.d.ts 118 KB

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