babylon.viewer.module.d.ts 117 KB

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