babylon.viewer.module.d.ts 117 KB

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