babylon.viewer.module.d.ts 107 KB

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