babylon.viewer.module.d.ts 118 KB

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