babylonjs.loaders.d.ts 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877
  1. declare module BABYLON {
  2. class STLFileLoader implements ISceneLoaderPlugin {
  3. solidPattern: RegExp;
  4. facetsPattern: RegExp;
  5. normalPattern: RegExp;
  6. vertexPattern: RegExp;
  7. name: string;
  8. extensions: ISceneLoaderPluginExtensions;
  9. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  10. load(scene: Scene, data: any, rootUrl: string): boolean;
  11. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12. private isBinary;
  13. private parseBinary;
  14. private parseASCII;
  15. }
  16. }
  17. declare module BABYLON {
  18. /**
  19. * Class reading and parsing the MTL file bundled with the obj file.
  20. */
  21. class MTLFileLoader {
  22. materials: BABYLON.StandardMaterial[];
  23. /**
  24. * This function will read the mtl file and create each material described inside
  25. * This function could be improve by adding :
  26. * -some component missing (Ni, Tf...)
  27. * -including the specific options available
  28. *
  29. * @param scene
  30. * @param data
  31. * @param rootUrl
  32. */
  33. parseMTL(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string): void;
  34. /**
  35. * Gets the texture for the material.
  36. *
  37. * If the material is imported from input file,
  38. * We sanitize the url to ensure it takes the textre from aside the material.
  39. *
  40. * @param rootUrl The root url to load from
  41. * @param value The value stored in the mtl
  42. * @return The Texture
  43. */
  44. private static _getTexture;
  45. }
  46. class OBJFileLoader implements ISceneLoaderPluginAsync {
  47. static OPTIMIZE_WITH_UV: boolean;
  48. /**
  49. * Invert model on y-axis (does a model scaling inversion)
  50. */
  51. static INVERT_Y: boolean;
  52. /**
  53. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  54. */
  55. static IMPORT_VERTEX_COLORS: boolean;
  56. /**
  57. * Compute the normals for the model, even if normals are present in the file
  58. */
  59. static COMPUTE_NORMALS: boolean;
  60. name: string;
  61. extensions: string;
  62. obj: RegExp;
  63. group: RegExp;
  64. mtllib: RegExp;
  65. usemtl: RegExp;
  66. smooth: RegExp;
  67. vertexPattern: RegExp;
  68. normalPattern: RegExp;
  69. uvPattern: RegExp;
  70. facePattern1: RegExp;
  71. facePattern2: RegExp;
  72. facePattern3: RegExp;
  73. facePattern4: RegExp;
  74. facePattern5: RegExp;
  75. /**
  76. * Calls synchronously the MTL file attached to this obj.
  77. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  78. * Without this function materials are not displayed in the first frame (but displayed after).
  79. * In consequence it is impossible to get material information in your HTML file
  80. *
  81. * @param url The URL of the MTL file
  82. * @param rootUrl
  83. * @param onSuccess Callback function to be called when the MTL file is loaded
  84. * @private
  85. */
  86. private _loadMTL;
  87. /**
  88. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  90. * @param scene the scene the meshes should be added to
  91. * @param data the OBJ data to load
  92. * @param rootUrl root url to load from
  93. * @param onProgress event that fires when loading progress has occured
  94. * @param fileName Defines the name of the file to load
  95. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  96. */
  97. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98. meshes: AbstractMesh[];
  99. particleSystems: IParticleSystem[];
  100. skeletons: Skeleton[];
  101. animationGroups: AnimationGroup[];
  102. }>;
  103. /**
  104. * Imports all objects from the loaded OBJ data and adds them to the scene
  105. *
  106. * @param scene the scene the objects should be added to
  107. * @param data the OBJ data to load
  108. * @param rootUrl root url to load from
  109. * @param onProgress event that fires when loading progress has occured
  110. * @param fileName Defines the name of the file to load
  111. * @returns a promise which completes when objects have been loaded to the scene
  112. */
  113. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  114. /**
  115. * Load into an asset container.
  116. * @param scene The scene to load into
  117. * @param data The data to import
  118. * @param rootUrl The root url for scene and resources
  119. * @param onProgress The callback when the load progresses
  120. * @param fileName Defines the name of the file to load
  121. * @returns The loaded asset container
  122. */
  123. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124. /**
  125. * Read the OBJ file and create an Array of meshes.
  126. * Each mesh contains all information given by the OBJ and the MTL file.
  127. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  128. *
  129. * @param meshesNames
  130. * @param scene BABYLON.Scene The scene where are displayed the data
  131. * @param data String The content of the obj file
  132. * @param rootUrl String The path to the folder
  133. * @returns Array<AbstractMesh>
  134. * @private
  135. */
  136. private _parseSolid;
  137. }
  138. }
  139. declare module BABYLON {
  140. /**
  141. * Mode that determines the coordinate system to use.
  142. */
  143. enum GLTFLoaderCoordinateSystemMode {
  144. /**
  145. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  146. */
  147. AUTO = 0,
  148. /**
  149. * Sets the useRightHandedSystem flag on the scene.
  150. */
  151. FORCE_RIGHT_HANDED = 1
  152. }
  153. /**
  154. * Mode that determines what animations will start.
  155. */
  156. enum GLTFLoaderAnimationStartMode {
  157. /**
  158. * No animation will start.
  159. */
  160. NONE = 0,
  161. /**
  162. * The first animation will start.
  163. */
  164. FIRST = 1,
  165. /**
  166. * All animations will start.
  167. */
  168. ALL = 2
  169. }
  170. /**
  171. * Interface that contains the data for the glTF asset.
  172. */
  173. interface IGLTFLoaderData {
  174. /**
  175. * Object that represents the glTF JSON.
  176. */
  177. json: Object;
  178. /**
  179. * The BIN chunk of a binary glTF.
  180. */
  181. bin: Nullable<ArrayBufferView>;
  182. }
  183. /**
  184. * Interface for extending the loader.
  185. */
  186. interface IGLTFLoaderExtension {
  187. /**
  188. * The name of this extension.
  189. */
  190. readonly name: string;
  191. /**
  192. * Defines whether this extension is enabled.
  193. */
  194. enabled: boolean;
  195. }
  196. /**
  197. * Loader state.
  198. */
  199. enum GLTFLoaderState {
  200. /**
  201. * The asset is loading.
  202. */
  203. LOADING = 0,
  204. /**
  205. * The asset is ready for rendering.
  206. */
  207. READY = 1,
  208. /**
  209. * The asset is completely loaded.
  210. */
  211. COMPLETE = 2
  212. }
  213. /** @hidden */
  214. interface IGLTFLoader extends IDisposable {
  215. readonly state: Nullable<GLTFLoaderState>;
  216. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  217. meshes: AbstractMesh[];
  218. particleSystems: IParticleSystem[];
  219. skeletons: Skeleton[];
  220. animationGroups: AnimationGroup[];
  221. }>;
  222. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  223. }
  224. /**
  225. * File loader for loading glTF files into a scene.
  226. */
  227. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  228. /** @hidden */
  229. static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  230. /** @hidden */
  231. static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  232. /**
  233. * Raised when the asset has been parsed
  234. */
  235. onParsedObservable: Observable<IGLTFLoaderData>;
  236. private _onParsedObserver;
  237. /**
  238. * Raised when the asset has been parsed
  239. */
  240. onParsed: (loaderData: IGLTFLoaderData) => void;
  241. /**
  242. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  243. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  244. * Defaults to true.
  245. * @hidden
  246. */
  247. static IncrementalLoading: boolean;
  248. /**
  249. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  250. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  251. * @hidden
  252. */
  253. static HomogeneousCoordinates: boolean;
  254. /**
  255. * The coordinate system mode. Defaults to AUTO.
  256. */
  257. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  258. /**
  259. * The animation start mode. Defaults to FIRST.
  260. */
  261. animationStartMode: GLTFLoaderAnimationStartMode;
  262. /**
  263. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  264. */
  265. compileMaterials: boolean;
  266. /**
  267. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  268. */
  269. useClipPlane: boolean;
  270. /**
  271. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  272. */
  273. compileShadowGenerators: boolean;
  274. /**
  275. * Defines if the Alpha blended materials are only applied as coverage.
  276. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  277. * If true, no extra effects are applied to transparent pixels.
  278. */
  279. transparencyAsCoverage: boolean;
  280. /**
  281. * Function called before loading a url referenced by the asset.
  282. */
  283. preprocessUrlAsync: (url: string) => Promise<string>;
  284. /**
  285. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  286. */
  287. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  288. private _onMeshLoadedObserver;
  289. /**
  290. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  291. */
  292. onMeshLoaded: (mesh: AbstractMesh) => void;
  293. /**
  294. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  295. */
  296. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  297. private _onTextureLoadedObserver;
  298. /**
  299. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  300. */
  301. onTextureLoaded: (texture: BaseTexture) => void;
  302. /**
  303. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  304. */
  305. readonly onMaterialLoadedObservable: Observable<Material>;
  306. private _onMaterialLoadedObserver;
  307. /**
  308. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  309. */
  310. onMaterialLoaded: (material: Material) => void;
  311. /**
  312. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  313. */
  314. readonly onCameraLoadedObservable: Observable<Camera>;
  315. private _onCameraLoadedObserver;
  316. /**
  317. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  318. */
  319. onCameraLoaded: (camera: Camera) => void;
  320. /**
  321. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  322. * For assets with LODs, raised when all of the LODs are complete.
  323. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  324. */
  325. readonly onCompleteObservable: Observable<void>;
  326. private _onCompleteObserver;
  327. /**
  328. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  329. * For assets with LODs, raised when all of the LODs are complete.
  330. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  331. */
  332. onComplete: () => void;
  333. /**
  334. * Observable raised when an error occurs.
  335. */
  336. readonly onErrorObservable: Observable<any>;
  337. private _onErrorObserver;
  338. /**
  339. * Callback raised when an error occurs.
  340. */
  341. onError: (reason: any) => void;
  342. /**
  343. * Observable raised after the loader is disposed.
  344. */
  345. readonly onDisposeObservable: Observable<void>;
  346. private _onDisposeObserver;
  347. /**
  348. * Callback raised after the loader is disposed.
  349. */
  350. onDispose: () => void;
  351. /**
  352. * Observable raised after a loader extension is created.
  353. * Set additional options for a loader extension in this event.
  354. */
  355. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  356. private _onExtensionLoadedObserver;
  357. /**
  358. * Callback raised after a loader extension is created.
  359. */
  360. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  361. /**
  362. * Defines if the loader logging is enabled.
  363. */
  364. loggingEnabled: boolean;
  365. /**
  366. * Defines if the loader should capture performance counters.
  367. */
  368. capturePerformanceCounters: boolean;
  369. /**
  370. * Defines if the loader should validate the asset.
  371. */
  372. validate: boolean;
  373. /**
  374. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  375. */
  376. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  377. private _onValidatedObserver;
  378. /**
  379. * Callback raised after a loader extension is created.
  380. */
  381. onValidated: (results: IGLTFValidationResults) => void;
  382. private _loader;
  383. /**
  384. * Name of the loader ("gltf")
  385. */
  386. name: string;
  387. /**
  388. * Supported file extensions of the loader (.gltf, .glb)
  389. */
  390. extensions: ISceneLoaderPluginExtensions;
  391. /**
  392. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  393. */
  394. dispose(): void;
  395. /** @hidden */
  396. _clear(): void;
  397. /**
  398. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  399. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  400. * @param scene the scene the meshes should be added to
  401. * @param data the glTF data to load
  402. * @param rootUrl root url to load from
  403. * @param onProgress event that fires when loading progress has occured
  404. * @param fileName Defines the name of the file to load
  405. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  406. */
  407. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  408. meshes: AbstractMesh[];
  409. particleSystems: IParticleSystem[];
  410. skeletons: Skeleton[];
  411. animationGroups: AnimationGroup[];
  412. }>;
  413. /**
  414. * Imports all objects from the loaded glTF data and adds them to the scene
  415. * @param scene the scene the objects should be added to
  416. * @param data the glTF data to load
  417. * @param rootUrl root url to load from
  418. * @param onProgress event that fires when loading progress has occured
  419. * @param fileName Defines the name of the file to load
  420. * @returns a promise which completes when objects have been loaded to the scene
  421. */
  422. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  423. /**
  424. * Load into an asset container.
  425. * @param scene The scene to load into
  426. * @param data The data to import
  427. * @param rootUrl The root url for scene and resources
  428. * @param onProgress The callback when the load progresses
  429. * @param fileName Defines the name of the file to load
  430. * @returns The loaded asset container
  431. */
  432. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  433. /**
  434. * If the data string can be loaded directly.
  435. * @param data string contianing the file data
  436. * @returns if the data can be loaded directly
  437. */
  438. canDirectLoad(data: string): boolean;
  439. /**
  440. * Rewrites a url by combining a root url and response url.
  441. */
  442. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  443. /**
  444. * Instantiates a glTF file loader plugin.
  445. * @returns the created plugin
  446. */
  447. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  448. /**
  449. * The loader state or null if the loader is not active.
  450. */
  451. readonly loaderState: Nullable<GLTFLoaderState>;
  452. /**
  453. * Returns a promise that resolves when the asset is completely loaded.
  454. * @returns a promise that resolves when the asset is completely loaded.
  455. */
  456. whenCompleteAsync(): Promise<void>;
  457. private _parseAsync;
  458. private _validateAsync;
  459. private _getLoader;
  460. private _unpackBinary;
  461. private _unpackBinaryV1;
  462. private _unpackBinaryV2;
  463. private static _parseVersion;
  464. private static _compareVersion;
  465. private static _decodeBufferToText;
  466. private static readonly _logSpaces;
  467. private _logIndentLevel;
  468. private _loggingEnabled;
  469. /** @hidden */
  470. _log: (message: string) => void;
  471. /** @hidden */
  472. _logOpen(message: string): void;
  473. /** @hidden */
  474. _logClose(): void;
  475. private _logEnabled;
  476. private _logDisabled;
  477. private _capturePerformanceCounters;
  478. /** @hidden */
  479. _startPerformanceCounter: (counterName: string) => void;
  480. /** @hidden */
  481. _endPerformanceCounter: (counterName: string) => void;
  482. private _startPerformanceCounterEnabled;
  483. private _startPerformanceCounterDisabled;
  484. private _endPerformanceCounterEnabled;
  485. private _endPerformanceCounterDisabled;
  486. }
  487. }
  488. declare module BABYLON.GLTF1 {
  489. /**
  490. * Enums
  491. */
  492. enum EComponentType {
  493. BYTE = 5120,
  494. UNSIGNED_BYTE = 5121,
  495. SHORT = 5122,
  496. UNSIGNED_SHORT = 5123,
  497. FLOAT = 5126
  498. }
  499. enum EShaderType {
  500. FRAGMENT = 35632,
  501. VERTEX = 35633
  502. }
  503. enum EParameterType {
  504. BYTE = 5120,
  505. UNSIGNED_BYTE = 5121,
  506. SHORT = 5122,
  507. UNSIGNED_SHORT = 5123,
  508. INT = 5124,
  509. UNSIGNED_INT = 5125,
  510. FLOAT = 5126,
  511. FLOAT_VEC2 = 35664,
  512. FLOAT_VEC3 = 35665,
  513. FLOAT_VEC4 = 35666,
  514. INT_VEC2 = 35667,
  515. INT_VEC3 = 35668,
  516. INT_VEC4 = 35669,
  517. BOOL = 35670,
  518. BOOL_VEC2 = 35671,
  519. BOOL_VEC3 = 35672,
  520. BOOL_VEC4 = 35673,
  521. FLOAT_MAT2 = 35674,
  522. FLOAT_MAT3 = 35675,
  523. FLOAT_MAT4 = 35676,
  524. SAMPLER_2D = 35678
  525. }
  526. enum ETextureWrapMode {
  527. CLAMP_TO_EDGE = 33071,
  528. MIRRORED_REPEAT = 33648,
  529. REPEAT = 10497
  530. }
  531. enum ETextureFilterType {
  532. NEAREST = 9728,
  533. LINEAR = 9728,
  534. NEAREST_MIPMAP_NEAREST = 9984,
  535. LINEAR_MIPMAP_NEAREST = 9985,
  536. NEAREST_MIPMAP_LINEAR = 9986,
  537. LINEAR_MIPMAP_LINEAR = 9987
  538. }
  539. enum ETextureFormat {
  540. ALPHA = 6406,
  541. RGB = 6407,
  542. RGBA = 6408,
  543. LUMINANCE = 6409,
  544. LUMINANCE_ALPHA = 6410
  545. }
  546. enum ECullingType {
  547. FRONT = 1028,
  548. BACK = 1029,
  549. FRONT_AND_BACK = 1032
  550. }
  551. enum EBlendingFunction {
  552. ZERO = 0,
  553. ONE = 1,
  554. SRC_COLOR = 768,
  555. ONE_MINUS_SRC_COLOR = 769,
  556. DST_COLOR = 774,
  557. ONE_MINUS_DST_COLOR = 775,
  558. SRC_ALPHA = 770,
  559. ONE_MINUS_SRC_ALPHA = 771,
  560. DST_ALPHA = 772,
  561. ONE_MINUS_DST_ALPHA = 773,
  562. CONSTANT_COLOR = 32769,
  563. ONE_MINUS_CONSTANT_COLOR = 32770,
  564. CONSTANT_ALPHA = 32771,
  565. ONE_MINUS_CONSTANT_ALPHA = 32772,
  566. SRC_ALPHA_SATURATE = 776
  567. }
  568. /**
  569. * Interfaces
  570. */
  571. interface IGLTFProperty {
  572. extensions?: {
  573. [key: string]: any;
  574. };
  575. extras?: Object;
  576. }
  577. interface IGLTFChildRootProperty extends IGLTFProperty {
  578. name?: string;
  579. }
  580. interface IGLTFAccessor extends IGLTFChildRootProperty {
  581. bufferView: string;
  582. byteOffset: number;
  583. byteStride: number;
  584. count: number;
  585. type: string;
  586. componentType: EComponentType;
  587. max?: number[];
  588. min?: number[];
  589. name?: string;
  590. }
  591. interface IGLTFBufferView extends IGLTFChildRootProperty {
  592. buffer: string;
  593. byteOffset: number;
  594. byteLength: number;
  595. byteStride: number;
  596. target?: number;
  597. }
  598. interface IGLTFBuffer extends IGLTFChildRootProperty {
  599. uri: string;
  600. byteLength?: number;
  601. type?: string;
  602. }
  603. interface IGLTFShader extends IGLTFChildRootProperty {
  604. uri: string;
  605. type: EShaderType;
  606. }
  607. interface IGLTFProgram extends IGLTFChildRootProperty {
  608. attributes: string[];
  609. fragmentShader: string;
  610. vertexShader: string;
  611. }
  612. interface IGLTFTechniqueParameter {
  613. type: number;
  614. count?: number;
  615. semantic?: string;
  616. node?: string;
  617. value?: number | boolean | string | Array<any>;
  618. source?: string;
  619. babylonValue?: any;
  620. }
  621. interface IGLTFTechniqueCommonProfile {
  622. lightingModel: string;
  623. texcoordBindings: Object;
  624. parameters?: Array<any>;
  625. }
  626. interface IGLTFTechniqueStatesFunctions {
  627. blendColor?: number[];
  628. blendEquationSeparate?: number[];
  629. blendFuncSeparate?: number[];
  630. colorMask: boolean[];
  631. cullFace: number[];
  632. }
  633. interface IGLTFTechniqueStates {
  634. enable: number[];
  635. functions: IGLTFTechniqueStatesFunctions;
  636. }
  637. interface IGLTFTechnique extends IGLTFChildRootProperty {
  638. parameters: {
  639. [key: string]: IGLTFTechniqueParameter;
  640. };
  641. program: string;
  642. attributes: {
  643. [key: string]: string;
  644. };
  645. uniforms: {
  646. [key: string]: string;
  647. };
  648. states: IGLTFTechniqueStates;
  649. }
  650. interface IGLTFMaterial extends IGLTFChildRootProperty {
  651. technique?: string;
  652. values: string[];
  653. }
  654. interface IGLTFMeshPrimitive extends IGLTFProperty {
  655. attributes: {
  656. [key: string]: string;
  657. };
  658. indices: string;
  659. material: string;
  660. mode?: number;
  661. }
  662. interface IGLTFMesh extends IGLTFChildRootProperty {
  663. primitives: IGLTFMeshPrimitive[];
  664. }
  665. interface IGLTFImage extends IGLTFChildRootProperty {
  666. uri: string;
  667. }
  668. interface IGLTFSampler extends IGLTFChildRootProperty {
  669. magFilter?: number;
  670. minFilter?: number;
  671. wrapS?: number;
  672. wrapT?: number;
  673. }
  674. interface IGLTFTexture extends IGLTFChildRootProperty {
  675. sampler: string;
  676. source: string;
  677. format?: ETextureFormat;
  678. internalFormat?: ETextureFormat;
  679. target?: number;
  680. type?: number;
  681. babylonTexture?: Texture;
  682. }
  683. interface IGLTFAmbienLight {
  684. color?: number[];
  685. }
  686. interface IGLTFDirectionalLight {
  687. color?: number[];
  688. }
  689. interface IGLTFPointLight {
  690. color?: number[];
  691. constantAttenuation?: number;
  692. linearAttenuation?: number;
  693. quadraticAttenuation?: number;
  694. }
  695. interface IGLTFSpotLight {
  696. color?: number[];
  697. constantAttenuation?: number;
  698. fallOfAngle?: number;
  699. fallOffExponent?: number;
  700. linearAttenuation?: number;
  701. quadraticAttenuation?: number;
  702. }
  703. interface IGLTFLight extends IGLTFChildRootProperty {
  704. type: string;
  705. }
  706. interface IGLTFCameraOrthographic {
  707. xmag: number;
  708. ymag: number;
  709. zfar: number;
  710. znear: number;
  711. }
  712. interface IGLTFCameraPerspective {
  713. aspectRatio: number;
  714. yfov: number;
  715. zfar: number;
  716. znear: number;
  717. }
  718. interface IGLTFCamera extends IGLTFChildRootProperty {
  719. type: string;
  720. }
  721. interface IGLTFAnimationChannelTarget {
  722. id: string;
  723. path: string;
  724. }
  725. interface IGLTFAnimationChannel {
  726. sampler: string;
  727. target: IGLTFAnimationChannelTarget;
  728. }
  729. interface IGLTFAnimationSampler {
  730. input: string;
  731. output: string;
  732. interpolation?: string;
  733. }
  734. interface IGLTFAnimation extends IGLTFChildRootProperty {
  735. channels?: IGLTFAnimationChannel[];
  736. parameters?: {
  737. [key: string]: string;
  738. };
  739. samplers?: {
  740. [key: string]: IGLTFAnimationSampler;
  741. };
  742. }
  743. interface IGLTFNodeInstanceSkin {
  744. skeletons: string[];
  745. skin: string;
  746. meshes: string[];
  747. }
  748. interface IGLTFSkins extends IGLTFChildRootProperty {
  749. bindShapeMatrix: number[];
  750. inverseBindMatrices: string;
  751. jointNames: string[];
  752. babylonSkeleton?: Skeleton;
  753. }
  754. interface IGLTFNode extends IGLTFChildRootProperty {
  755. camera?: string;
  756. children: string[];
  757. skin?: string;
  758. jointName?: string;
  759. light?: string;
  760. matrix: number[];
  761. mesh?: string;
  762. meshes?: string[];
  763. rotation?: number[];
  764. scale?: number[];
  765. translation?: number[];
  766. babylonNode?: Node;
  767. }
  768. interface IGLTFScene extends IGLTFChildRootProperty {
  769. nodes: string[];
  770. }
  771. /**
  772. * Runtime
  773. */
  774. interface IGLTFRuntime {
  775. extensions: {
  776. [key: string]: any;
  777. };
  778. accessors: {
  779. [key: string]: IGLTFAccessor;
  780. };
  781. buffers: {
  782. [key: string]: IGLTFBuffer;
  783. };
  784. bufferViews: {
  785. [key: string]: IGLTFBufferView;
  786. };
  787. meshes: {
  788. [key: string]: IGLTFMesh;
  789. };
  790. lights: {
  791. [key: string]: IGLTFLight;
  792. };
  793. cameras: {
  794. [key: string]: IGLTFCamera;
  795. };
  796. nodes: {
  797. [key: string]: IGLTFNode;
  798. };
  799. images: {
  800. [key: string]: IGLTFImage;
  801. };
  802. textures: {
  803. [key: string]: IGLTFTexture;
  804. };
  805. shaders: {
  806. [key: string]: IGLTFShader;
  807. };
  808. programs: {
  809. [key: string]: IGLTFProgram;
  810. };
  811. samplers: {
  812. [key: string]: IGLTFSampler;
  813. };
  814. techniques: {
  815. [key: string]: IGLTFTechnique;
  816. };
  817. materials: {
  818. [key: string]: IGLTFMaterial;
  819. };
  820. animations: {
  821. [key: string]: IGLTFAnimation;
  822. };
  823. skins: {
  824. [key: string]: IGLTFSkins;
  825. };
  826. currentScene?: Object;
  827. scenes: {
  828. [key: string]: IGLTFScene;
  829. };
  830. extensionsUsed: string[];
  831. extensionsRequired?: string[];
  832. buffersCount: number;
  833. shaderscount: number;
  834. scene: Scene;
  835. rootUrl: string;
  836. loadedBufferCount: number;
  837. loadedBufferViews: {
  838. [name: string]: ArrayBufferView;
  839. };
  840. loadedShaderCount: number;
  841. importOnlyMeshes: boolean;
  842. importMeshesNames?: string[];
  843. dummyNodes: Node[];
  844. }
  845. /**
  846. * Bones
  847. */
  848. interface INodeToRoot {
  849. bone: Bone;
  850. node: IGLTFNode;
  851. id: string;
  852. }
  853. interface IJointNode {
  854. node: IGLTFNode;
  855. id: string;
  856. }
  857. }
  858. declare module BABYLON.GLTF1 {
  859. /**
  860. * Implementation of the base glTF spec
  861. */
  862. class GLTFLoaderBase {
  863. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  864. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  865. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  866. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  867. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  868. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  869. }
  870. /**
  871. * glTF V1 Loader
  872. */
  873. class GLTFLoader implements IGLTFLoader {
  874. static Extensions: {
  875. [name: string]: GLTFLoaderExtension;
  876. };
  877. static RegisterExtension(extension: GLTFLoaderExtension): void;
  878. state: Nullable<GLTFLoaderState>;
  879. dispose(): void;
  880. private _importMeshAsync;
  881. /**
  882. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  883. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  884. * @param scene the scene the meshes should be added to
  885. * @param data gltf data containing information of the meshes in a loaded file
  886. * @param rootUrl root url to load from
  887. * @param onProgress event that fires when loading progress has occured
  888. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  889. */
  890. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  891. meshes: AbstractMesh[];
  892. particleSystems: IParticleSystem[];
  893. skeletons: Skeleton[];
  894. animationGroups: AnimationGroup[];
  895. }>;
  896. private _loadAsync;
  897. /**
  898. * Imports all objects from a loaded gltf file and adds them to the scene
  899. * @param scene the scene the objects should be added to
  900. * @param data gltf data containing information of the meshes in a loaded file
  901. * @param rootUrl root url to load from
  902. * @param onProgress event that fires when loading progress has occured
  903. * @returns a promise which completes when objects have been loaded to the scene
  904. */
  905. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  906. private _loadShadersAsync;
  907. private _loadBuffersAsync;
  908. private _createNodes;
  909. }
  910. }
  911. declare module BABYLON.GLTF1 {
  912. /**
  913. * Utils functions for GLTF
  914. */
  915. class GLTFUtils {
  916. /**
  917. * Sets the given "parameter" matrix
  918. * @param scene: the Scene object
  919. * @param source: the source node where to pick the matrix
  920. * @param parameter: the GLTF technique parameter
  921. * @param uniformName: the name of the shader's uniform
  922. * @param shaderMaterial: the shader material
  923. */
  924. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  925. /**
  926. * Sets the given "parameter" matrix
  927. * @param shaderMaterial: the shader material
  928. * @param uniform: the name of the shader's uniform
  929. * @param value: the value of the uniform
  930. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  931. */
  932. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  933. /**
  934. * Returns the wrap mode of the texture
  935. * @param mode: the mode value
  936. */
  937. static GetWrapMode(mode: number): number;
  938. /**
  939. * Returns the byte stride giving an accessor
  940. * @param accessor: the GLTF accessor objet
  941. */
  942. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  943. /**
  944. * Returns the texture filter mode giving a mode value
  945. * @param mode: the filter mode value
  946. */
  947. static GetTextureFilterMode(mode: number): ETextureFilterType;
  948. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  949. /**
  950. * Returns a buffer from its accessor
  951. * @param gltfRuntime: the GLTF runtime
  952. * @param accessor: the GLTF accessor
  953. */
  954. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  955. /**
  956. * Decodes a buffer view into a string
  957. * @param view: the buffer view
  958. */
  959. static DecodeBufferToText(view: ArrayBufferView): string;
  960. /**
  961. * Returns the default material of gltf. Related to
  962. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  963. * @param scene: the Babylon.js scene
  964. */
  965. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  966. private static _DefaultMaterial;
  967. }
  968. }
  969. declare module BABYLON.GLTF1 {
  970. abstract class GLTFLoaderExtension {
  971. private _name;
  972. constructor(name: string);
  973. readonly name: string;
  974. /**
  975. * Defines an override for loading the runtime
  976. * Return true to stop further extensions from loading the runtime
  977. */
  978. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  979. /**
  980. * Defines an onverride for creating gltf runtime
  981. * Return true to stop further extensions from creating the runtime
  982. */
  983. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  984. /**
  985. * Defines an override for loading buffers
  986. * Return true to stop further extensions from loading this buffer
  987. */
  988. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  989. /**
  990. * Defines an override for loading texture buffers
  991. * Return true to stop further extensions from loading this texture data
  992. */
  993. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  994. /**
  995. * Defines an override for creating textures
  996. * Return true to stop further extensions from loading this texture
  997. */
  998. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  999. /**
  1000. * Defines an override for loading shader strings
  1001. * Return true to stop further extensions from loading this shader data
  1002. */
  1003. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  1004. /**
  1005. * Defines an override for loading materials
  1006. * Return true to stop further extensions from loading this material
  1007. */
  1008. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  1009. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  1010. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  1011. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  1012. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  1013. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  1014. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  1015. private static LoadTextureBufferAsync;
  1016. private static CreateTextureAsync;
  1017. private static ApplyExtensions;
  1018. }
  1019. }
  1020. declare module BABYLON.GLTF1 {
  1021. class GLTFBinaryExtension extends GLTFLoaderExtension {
  1022. private _bin;
  1023. constructor();
  1024. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  1025. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  1026. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  1027. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  1028. }
  1029. }
  1030. declare module BABYLON.GLTF1 {
  1031. class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  1032. constructor();
  1033. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  1034. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  1035. private _loadTexture;
  1036. }
  1037. }
  1038. declare module BABYLON.GLTF2.Loader {
  1039. /**
  1040. * Loader interface with an index field.
  1041. */
  1042. interface IArrayItem {
  1043. /**
  1044. * The index of this item in the array.
  1045. */
  1046. index: number;
  1047. }
  1048. /**
  1049. * Loader interface with additional members.
  1050. */
  1051. interface IAccessor extends GLTF2.IAccessor, IArrayItem {
  1052. /** @hidden */
  1053. _data?: Promise<ArrayBufferView>;
  1054. /** @hidden */
  1055. _babylonVertexBuffer?: Promise<VertexBuffer>;
  1056. }
  1057. /**
  1058. * Loader interface with additional members.
  1059. */
  1060. interface IAnimationChannel extends GLTF2.IAnimationChannel, IArrayItem {
  1061. }
  1062. /** @hidden */
  1063. interface _IAnimationSamplerData {
  1064. input: Float32Array;
  1065. interpolation: AnimationSamplerInterpolation;
  1066. output: Float32Array;
  1067. }
  1068. /**
  1069. * Loader interface with additional members.
  1070. */
  1071. interface IAnimationSampler extends GLTF2.IAnimationSampler, IArrayItem {
  1072. /** @hidden */
  1073. _data?: Promise<_IAnimationSamplerData>;
  1074. }
  1075. /**
  1076. * Loader interface with additional members.
  1077. */
  1078. interface IAnimation extends GLTF2.IAnimation, IArrayItem {
  1079. channels: IAnimationChannel[];
  1080. samplers: IAnimationSampler[];
  1081. /** @hidden */
  1082. _babylonAnimationGroup?: AnimationGroup;
  1083. }
  1084. /**
  1085. * Loader interface with additional members.
  1086. */
  1087. interface IBuffer extends GLTF2.IBuffer, IArrayItem {
  1088. /** @hidden */
  1089. _data?: Promise<ArrayBufferView>;
  1090. }
  1091. /**
  1092. * Loader interface with additional members.
  1093. */
  1094. interface IBufferView extends GLTF2.IBufferView, IArrayItem {
  1095. /** @hidden */
  1096. _data?: Promise<ArrayBufferView>;
  1097. /** @hidden */
  1098. _babylonBuffer?: Promise<Buffer>;
  1099. }
  1100. /**
  1101. * Loader interface with additional members.
  1102. */
  1103. interface ICamera extends GLTF2.ICamera, IArrayItem {
  1104. }
  1105. /**
  1106. * Loader interface with additional members.
  1107. */
  1108. interface IImage extends GLTF2.IImage, IArrayItem {
  1109. /** @hidden */
  1110. _data?: Promise<ArrayBufferView>;
  1111. }
  1112. /**
  1113. * Loader interface with additional members.
  1114. */
  1115. interface IMaterialNormalTextureInfo extends GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  1116. }
  1117. /**
  1118. * Loader interface with additional members.
  1119. */
  1120. interface IMaterialOcclusionTextureInfo extends GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  1121. }
  1122. /**
  1123. * Loader interface with additional members.
  1124. */
  1125. interface IMaterialPbrMetallicRoughness extends GLTF2.IMaterialPbrMetallicRoughness {
  1126. baseColorTexture?: ITextureInfo;
  1127. metallicRoughnessTexture?: ITextureInfo;
  1128. }
  1129. /**
  1130. * Loader interface with additional members.
  1131. */
  1132. interface IMaterial extends GLTF2.IMaterial, IArrayItem {
  1133. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  1134. normalTexture?: IMaterialNormalTextureInfo;
  1135. occlusionTexture?: IMaterialOcclusionTextureInfo;
  1136. emissiveTexture?: ITextureInfo;
  1137. /** @hidden */
  1138. _data?: {
  1139. [babylonDrawMode: number]: {
  1140. babylonMaterial: Material;
  1141. babylonMeshes: AbstractMesh[];
  1142. promise: Promise<void>;
  1143. };
  1144. };
  1145. }
  1146. /**
  1147. * Loader interface with additional members.
  1148. */
  1149. interface IMesh extends GLTF2.IMesh, IArrayItem {
  1150. primitives: IMeshPrimitive[];
  1151. }
  1152. /**
  1153. * Loader interface with additional members.
  1154. */
  1155. interface IMeshPrimitive extends GLTF2.IMeshPrimitive, IArrayItem {
  1156. /** @hidden */
  1157. _instanceData?: {
  1158. babylonSourceMesh: Mesh;
  1159. promise: Promise<any>;
  1160. };
  1161. }
  1162. /**
  1163. * Loader interface with additional members.
  1164. */
  1165. interface INode extends GLTF2.INode, IArrayItem {
  1166. /**
  1167. * The parent glTF node.
  1168. */
  1169. parent?: INode;
  1170. /** @hidden */
  1171. _babylonTransformNode?: TransformNode;
  1172. /** @hidden */
  1173. _primitiveBabylonMeshes?: AbstractMesh[];
  1174. /** @hidden */
  1175. _babylonBones?: Bone[];
  1176. /** @hidden */
  1177. _numMorphTargets?: number;
  1178. }
  1179. /** @hidden */
  1180. interface _ISamplerData {
  1181. noMipMaps: boolean;
  1182. samplingMode: number;
  1183. wrapU: number;
  1184. wrapV: number;
  1185. }
  1186. /**
  1187. * Loader interface with additional members.
  1188. */
  1189. interface ISampler extends GLTF2.ISampler, IArrayItem {
  1190. /** @hidden */
  1191. _data?: _ISamplerData;
  1192. }
  1193. /**
  1194. * Loader interface with additional members.
  1195. */
  1196. interface IScene extends GLTF2.IScene, IArrayItem {
  1197. }
  1198. /**
  1199. * Loader interface with additional members.
  1200. */
  1201. interface ISkin extends GLTF2.ISkin, IArrayItem {
  1202. /** @hidden */
  1203. _data?: {
  1204. babylonSkeleton: Skeleton;
  1205. promise: Promise<void>;
  1206. };
  1207. }
  1208. /**
  1209. * Loader interface with additional members.
  1210. */
  1211. interface ITexture extends GLTF2.ITexture, IArrayItem {
  1212. }
  1213. /**
  1214. * Loader interface with additional members.
  1215. */
  1216. interface ITextureInfo extends GLTF2.ITextureInfo {
  1217. }
  1218. /**
  1219. * Loader interface with additional members.
  1220. */
  1221. interface IGLTF extends GLTF2.IGLTF {
  1222. accessors?: IAccessor[];
  1223. animations?: IAnimation[];
  1224. buffers?: IBuffer[];
  1225. bufferViews?: IBufferView[];
  1226. cameras?: ICamera[];
  1227. images?: IImage[];
  1228. materials?: IMaterial[];
  1229. meshes?: IMesh[];
  1230. nodes?: INode[];
  1231. samplers?: ISampler[];
  1232. scenes?: IScene[];
  1233. skins?: ISkin[];
  1234. textures?: ITexture[];
  1235. }
  1236. }
  1237. /**
  1238. * Defines the module for importing and exporting glTF 2.0 assets
  1239. */
  1240. declare module BABYLON.GLTF2 {
  1241. /**
  1242. * Helper class for working with arrays when loading the glTF asset
  1243. */
  1244. class ArrayItem {
  1245. /**
  1246. * Gets an item from the given array.
  1247. * @param context The context when loading the asset
  1248. * @param array The array to get the item from
  1249. * @param index The index to the array
  1250. * @returns The array item
  1251. */
  1252. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1253. /**
  1254. * Assign an `index` field to each item of the given array.
  1255. * @param array The array of items
  1256. */
  1257. static Assign(array?: Loader.IArrayItem[]): void;
  1258. }
  1259. /**
  1260. * The glTF 2.0 loader
  1261. */
  1262. class GLTFLoader implements IGLTFLoader {
  1263. /** The glTF object parsed from the JSON. */
  1264. gltf: Loader.IGLTF;
  1265. /** The Babylon scene when loading the asset. */
  1266. babylonScene: Scene;
  1267. /** @hidden */
  1268. _completePromises: Promise<any>[];
  1269. private _disposed;
  1270. private _parent;
  1271. private _state;
  1272. private _extensions;
  1273. private _rootUrl;
  1274. private _fileName;
  1275. private _uniqueRootUrl;
  1276. private _rootBabylonMesh;
  1277. private _defaultBabylonMaterialData;
  1278. private _progressCallback?;
  1279. private _requests;
  1280. private static readonly _DefaultSampler;
  1281. private static _ExtensionNames;
  1282. private static _ExtensionFactories;
  1283. /**
  1284. * Registers a loader extension.
  1285. * @param name The name of the loader extension.
  1286. * @param factory The factory function that creates the loader extension.
  1287. */
  1288. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1289. /**
  1290. * Unregisters a loader extension.
  1291. * @param name The name of the loader extenion.
  1292. * @returns A boolean indicating whether the extension has been unregistered
  1293. */
  1294. static UnregisterExtension(name: string): boolean;
  1295. /**
  1296. * Gets the loader state.
  1297. */
  1298. readonly state: Nullable<GLTFLoaderState>;
  1299. /** @hidden */
  1300. constructor(parent: GLTFFileLoader);
  1301. /** @hidden */
  1302. dispose(): void;
  1303. /** @hidden */
  1304. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1305. meshes: AbstractMesh[];
  1306. particleSystems: IParticleSystem[];
  1307. skeletons: Skeleton[];
  1308. animationGroups: AnimationGroup[];
  1309. }>;
  1310. /** @hidden */
  1311. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1312. private _loadAsync;
  1313. private _loadData;
  1314. private _setupData;
  1315. private _loadExtensions;
  1316. private _checkExtensions;
  1317. private _setState;
  1318. private _createRootNode;
  1319. /**
  1320. * Loads a glTF scene.
  1321. * @param context The context when loading the asset
  1322. * @param scene The glTF scene property
  1323. * @returns A promise that resolves when the load is complete
  1324. */
  1325. loadSceneAsync(context: string, scene: Loader.IScene): Promise<void>;
  1326. private _forEachPrimitive;
  1327. private _getMeshes;
  1328. private _getSkeletons;
  1329. private _getAnimationGroups;
  1330. private _startAnimations;
  1331. /**
  1332. * Loads a glTF node.
  1333. * @param context The context when loading the asset
  1334. * @param node The glTF node property
  1335. * @param assign A function called synchronously after parsing the glTF properties
  1336. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1337. */
  1338. loadNodeAsync(context: string, node: Loader.INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1339. private _loadMeshAsync;
  1340. private _loadMeshPrimitiveAsync;
  1341. private _loadVertexDataAsync;
  1342. private _createMorphTargets;
  1343. private _loadMorphTargetsAsync;
  1344. private _loadMorphTargetVertexDataAsync;
  1345. private static _LoadTransform;
  1346. private _loadSkinAsync;
  1347. private _loadBones;
  1348. private _loadBone;
  1349. private _loadSkinInverseBindMatricesDataAsync;
  1350. private _updateBoneMatrices;
  1351. private _getNodeMatrix;
  1352. /**
  1353. * Loads a glTF camera.
  1354. * @param context The context when loading the asset
  1355. * @param camera The glTF camera property
  1356. * @param assign A function called synchronously after parsing the glTF properties
  1357. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1358. */
  1359. loadCameraAsync(context: string, camera: Loader.ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1360. private _loadAnimationsAsync;
  1361. /**
  1362. * Loads a glTF animation.
  1363. * @param context The context when loading the asset
  1364. * @param animation The glTF animation property
  1365. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1366. */
  1367. loadAnimationAsync(context: string, animation: Loader.IAnimation): Promise<AnimationGroup>;
  1368. private _loadAnimationChannelAsync;
  1369. private _loadAnimationSamplerAsync;
  1370. private _loadBufferAsync;
  1371. /**
  1372. * Loads a glTF buffer view.
  1373. * @param context The context when loading the asset
  1374. * @param bufferView The glTF buffer view property
  1375. * @returns A promise that resolves with the loaded data when the load is complete
  1376. */
  1377. loadBufferViewAsync(context: string, bufferView: Loader.IBufferView): Promise<ArrayBufferView>;
  1378. private _loadIndicesAccessorAsync;
  1379. private _loadFloatAccessorAsync;
  1380. private _loadVertexBufferViewAsync;
  1381. private _loadVertexAccessorAsync;
  1382. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1383. /** @hidden */
  1384. _loadMaterialAsync(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1385. private _createDefaultMaterial;
  1386. /**
  1387. * Creates a Babylon material from a glTF material.
  1388. * @param context The context when loading the asset
  1389. * @param material The glTF material property
  1390. * @param babylonDrawMode The draw mode for the Babylon material
  1391. * @returns The Babylon material
  1392. */
  1393. createMaterial(context: string, material: Loader.IMaterial, babylonDrawMode: number): Material;
  1394. /**
  1395. * Loads properties from a glTF material into a Babylon material.
  1396. * @param context The context when loading the asset
  1397. * @param material The glTF material property
  1398. * @param babylonMaterial The Babylon material
  1399. * @returns A promise that resolves when the load is complete
  1400. */
  1401. loadMaterialPropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
  1402. /**
  1403. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1404. * @param context The context when loading the asset
  1405. * @param material The glTF material property
  1406. * @param babylonMaterial The Babylon material
  1407. * @returns A promise that resolves when the load is complete
  1408. */
  1409. loadMaterialBasePropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
  1410. /**
  1411. * Loads the alpha properties from a glTF material into a Babylon material.
  1412. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1413. * @param context The context when loading the asset
  1414. * @param material The glTF material property
  1415. * @param babylonMaterial The Babylon material
  1416. */
  1417. loadMaterialAlphaProperties(context: string, material: Loader.IMaterial, babylonMaterial: Material): void;
  1418. /**
  1419. * Loads a glTF texture info.
  1420. * @param context The context when loading the asset
  1421. * @param textureInfo The glTF texture info property
  1422. * @param assign A function called synchronously after parsing the glTF properties
  1423. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1424. */
  1425. loadTextureInfoAsync(context: string, textureInfo: Loader.ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1426. private _loadTextureAsync;
  1427. private _loadSampler;
  1428. /**
  1429. * Loads a glTF image.
  1430. * @param context The context when loading the asset
  1431. * @param image The glTF image property
  1432. * @returns A promise that resolves with the loaded data when the load is complete
  1433. */
  1434. loadImageAsync(context: string, image: Loader.IImage): Promise<ArrayBufferView>;
  1435. /**
  1436. * Loads a glTF uri.
  1437. * @param context The context when loading the asset
  1438. * @param uri The base64 or relative uri
  1439. * @returns A promise that resolves with the loaded data when the load is complete
  1440. */
  1441. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  1442. private _onProgress;
  1443. /**
  1444. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1445. * @param babylonObject the Babylon object with metadata
  1446. * @param pointer the JSON pointer
  1447. */
  1448. static AddPointerMetadata(babylonObject: {
  1449. metadata: any;
  1450. }, pointer: string): void;
  1451. private static _GetTextureWrapMode;
  1452. private static _GetTextureSamplingMode;
  1453. private static _GetTypedArray;
  1454. private static _GetNumComponents;
  1455. private static _ValidateUri;
  1456. private static _GetDrawMode;
  1457. private _compileMaterialsAsync;
  1458. private _compileShadowGeneratorsAsync;
  1459. private _forEachExtensions;
  1460. private _applyExtensions;
  1461. private _extensionsOnLoading;
  1462. private _extensionsOnReady;
  1463. private _extensionsLoadSceneAsync;
  1464. private _extensionsLoadNodeAsync;
  1465. private _extensionsLoadCameraAsync;
  1466. private _extensionsLoadVertexDataAsync;
  1467. private _extensionsLoadMaterialAsync;
  1468. private _extensionsCreateMaterial;
  1469. private _extensionsLoadMaterialPropertiesAsync;
  1470. private _extensionsLoadTextureInfoAsync;
  1471. private _extensionsLoadAnimationAsync;
  1472. private _extensionsLoadUriAsync;
  1473. /**
  1474. * Helper method called by a loader extension to load an glTF extension.
  1475. * @param context The context when loading the asset
  1476. * @param property The glTF property to load the extension from
  1477. * @param extensionName The name of the extension to load
  1478. * @param actionAsync The action to run
  1479. * @returns The promise returned by actionAsync or null if the extension does not exist
  1480. */
  1481. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1482. /**
  1483. * Helper method called by a loader extension to load a glTF extra.
  1484. * @param context The context when loading the asset
  1485. * @param property The glTF property to load the extra from
  1486. * @param extensionName The name of the extension to load
  1487. * @param actionAsync The action to run
  1488. * @returns The promise returned by actionAsync or null if the extra does not exist
  1489. */
  1490. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1491. /**
  1492. * Increments the indentation level and logs a message.
  1493. * @param message The message to log
  1494. */
  1495. logOpen(message: string): void;
  1496. /**
  1497. * Decrements the indentation level.
  1498. */
  1499. logClose(): void;
  1500. /**
  1501. * Logs a message
  1502. * @param message The message to log
  1503. */
  1504. log(message: string): void;
  1505. /**
  1506. * Starts a performance counter.
  1507. * @param counterName The name of the performance counter
  1508. */
  1509. startPerformanceCounter(counterName: string): void;
  1510. /**
  1511. * Ends a performance counter.
  1512. * @param counterName The name of the performance counter
  1513. */
  1514. endPerformanceCounter(counterName: string): void;
  1515. }
  1516. }
  1517. declare module BABYLON.GLTF2 {
  1518. /**
  1519. * Interface for a glTF loader extension.
  1520. */
  1521. interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  1522. /**
  1523. * Called after the loader state changes to LOADING.
  1524. */
  1525. onLoading?(): void;
  1526. /**
  1527. * Called after the loader state changes to READY.
  1528. */
  1529. onReady?(): void;
  1530. /**
  1531. * Define this method to modify the default behavior when loading scenes.
  1532. * @param context The context when loading the asset
  1533. * @param scene The glTF scene property
  1534. * @returns A promise that resolves when the load is complete or null if not handled
  1535. */
  1536. loadSceneAsync?(context: string, scene: Loader.IScene): Nullable<Promise<void>>;
  1537. /**
  1538. * Define this method to modify the default behavior when loading nodes.
  1539. * @param context The context when loading the asset
  1540. * @param node The glTF node property
  1541. * @param assign A function called synchronously after parsing the glTF properties
  1542. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1543. */
  1544. loadNodeAsync?(context: string, node: Loader.INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1545. /**
  1546. * Define this method to modify the default behavior when loading cameras.
  1547. * @param context The context when loading the asset
  1548. * @param camera The glTF camera property
  1549. * @param assign A function called synchronously after parsing the glTF properties
  1550. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1551. */
  1552. loadCameraAsync?(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1553. /**
  1554. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1555. * @param context The context when loading the asset
  1556. * @param primitive The glTF mesh primitive property
  1557. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1558. */
  1559. _loadVertexDataAsync?(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1560. /**
  1561. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1562. * @param context The context when loading the asset
  1563. * @param material The glTF material property
  1564. * @param assign A function called synchronously after parsing the glTF properties
  1565. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1566. */
  1567. _loadMaterialAsync?(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1568. /**
  1569. * Define this method to modify the default behavior when creating materials.
  1570. * @param context The context when loading the asset
  1571. * @param material The glTF material property
  1572. * @param babylonDrawMode The draw mode for the Babylon material
  1573. * @returns The Babylon material or null if not handled
  1574. */
  1575. createMaterial?(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material>;
  1576. /**
  1577. * Define this method to modify the default behavior when loading material properties.
  1578. * @param context The context when loading the asset
  1579. * @param material The glTF material property
  1580. * @param babylonMaterial The Babylon material
  1581. * @returns A promise that resolves when the load is complete or null if not handled
  1582. */
  1583. loadMaterialPropertiesAsync?(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1584. /**
  1585. * Define this method to modify the default behavior when loading texture infos.
  1586. * @param context The context when loading the asset
  1587. * @param textureInfo The glTF texture info property
  1588. * @param assign A function called synchronously after parsing the glTF properties
  1589. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1590. */
  1591. loadTextureInfoAsync?(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1592. /**
  1593. * Define this method to modify the default behavior when loading animations.
  1594. * @param context The context when loading the asset
  1595. * @param animation The glTF animation property
  1596. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1597. */
  1598. loadAnimationAsync?(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>>;
  1599. /**
  1600. * Define this method to modify the default behavior when loading uris.
  1601. * @param context The context when loading the asset
  1602. * @param uri The uri to load
  1603. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1604. */
  1605. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1606. }
  1607. }
  1608. /**
  1609. * Defines the module for the built-in glTF 2.0 loader extensions.
  1610. */
  1611. declare module BABYLON.GLTF2.Loader.Extensions {
  1612. }
  1613. declare module BABYLON.GLTF2.Loader.Extensions {
  1614. /**
  1615. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1616. */
  1617. class MSFT_lod implements IGLTFLoaderExtension {
  1618. /** The name of this extension. */
  1619. readonly name: string;
  1620. /** Defines whether this extension is enabled. */
  1621. enabled: boolean;
  1622. /**
  1623. * Maximum number of LODs to load, starting from the lowest LOD.
  1624. */
  1625. maxLODsToLoad: number;
  1626. /**
  1627. * Observable raised when all node LODs of one level are loaded.
  1628. * The event data is the index of the loaded LOD starting from zero.
  1629. * Dispose the loader to cancel the loading of the next level of LODs.
  1630. */
  1631. onNodeLODsLoadedObservable: Observable<number>;
  1632. /**
  1633. * Observable raised when all material LODs of one level are loaded.
  1634. * The event data is the index of the loaded LOD starting from zero.
  1635. * Dispose the loader to cancel the loading of the next level of LODs.
  1636. */
  1637. onMaterialLODsLoadedObservable: Observable<number>;
  1638. private _loader;
  1639. private _nodeIndexLOD;
  1640. private _nodeSignalLODs;
  1641. private _nodePromiseLODs;
  1642. private _materialIndexLOD;
  1643. private _materialSignalLODs;
  1644. private _materialPromiseLODs;
  1645. /** @hidden */
  1646. constructor(loader: GLTFLoader);
  1647. /** @hidden */
  1648. dispose(): void;
  1649. /** @hidden */
  1650. onReady(): void;
  1651. /** @hidden */
  1652. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1653. /** @hidden */
  1654. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1655. /** @hidden */
  1656. _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1657. /**
  1658. * Gets an array of LOD properties from lowest to highest.
  1659. */
  1660. private _getLODs;
  1661. private _disposeUnusedMaterials;
  1662. }
  1663. }
  1664. declare module BABYLON.GLTF2.Loader.Extensions {
  1665. /** @hidden */
  1666. class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1667. readonly name: string;
  1668. enabled: boolean;
  1669. private _loader;
  1670. constructor(loader: GLTFLoader);
  1671. dispose(): void;
  1672. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1673. }
  1674. }
  1675. declare module BABYLON.GLTF2.Loader.Extensions {
  1676. /** @hidden */
  1677. class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1678. readonly name: string;
  1679. enabled: boolean;
  1680. private _loader;
  1681. constructor(loader: GLTFLoader);
  1682. dispose(): void;
  1683. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1684. }
  1685. }
  1686. declare module BABYLON.GLTF2.Loader.Extensions {
  1687. /**
  1688. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1689. */
  1690. class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1691. /** The name of this extension. */
  1692. readonly name: string;
  1693. /** Defines whether this extension is enabled. */
  1694. enabled: boolean;
  1695. private _loader;
  1696. private _clips;
  1697. private _emitters;
  1698. /** @hidden */
  1699. constructor(loader: GLTFLoader);
  1700. /** @hidden */
  1701. dispose(): void;
  1702. /** @hidden */
  1703. onLoading(): void;
  1704. /** @hidden */
  1705. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1706. /** @hidden */
  1707. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1708. /** @hidden */
  1709. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1710. private _loadClipAsync;
  1711. private _loadEmitterAsync;
  1712. private _getEventAction;
  1713. private _loadAnimationEventAsync;
  1714. }
  1715. }
  1716. declare module BABYLON.GLTF2.Loader.Extensions {
  1717. /**
  1718. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1719. */
  1720. class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1721. /** The name of this extension. */
  1722. readonly name: string;
  1723. /** Defines whether this extension is enabled. */
  1724. enabled: boolean;
  1725. private _loader;
  1726. private _dracoCompression?;
  1727. /** @hidden */
  1728. constructor(loader: GLTFLoader);
  1729. /** @hidden */
  1730. dispose(): void;
  1731. /** @hidden */
  1732. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1733. }
  1734. }
  1735. declare module BABYLON.GLTF2.Loader.Extensions {
  1736. /**
  1737. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1738. */
  1739. class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1740. /** The name of this extension. */
  1741. readonly name: string;
  1742. /** Defines whether this extension is enabled. */
  1743. enabled: boolean;
  1744. private _loader;
  1745. /** @hidden */
  1746. constructor(loader: GLTFLoader);
  1747. /** @hidden */
  1748. dispose(): void;
  1749. /** @hidden */
  1750. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1751. private _loadSpecularGlossinessPropertiesAsync;
  1752. }
  1753. }
  1754. declare module BABYLON.GLTF2.Loader.Extensions {
  1755. /**
  1756. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1757. */
  1758. class KHR_materials_unlit implements IGLTFLoaderExtension {
  1759. /** The name of this extension. */
  1760. readonly name: string;
  1761. /** Defines whether this extension is enabled. */
  1762. enabled: boolean;
  1763. private _loader;
  1764. /** @hidden */
  1765. constructor(loader: GLTFLoader);
  1766. /** @hidden */
  1767. dispose(): void;
  1768. /** @hidden */
  1769. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1770. private _loadUnlitPropertiesAsync;
  1771. }
  1772. }
  1773. declare module BABYLON.GLTF2.Loader.Extensions {
  1774. /**
  1775. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1776. */
  1777. class KHR_lights implements IGLTFLoaderExtension {
  1778. /** The name of this extension. */
  1779. readonly name: string;
  1780. /** Defines whether this extension is enabled. */
  1781. enabled: boolean;
  1782. private _loader;
  1783. private _lights?;
  1784. /** @hidden */
  1785. constructor(loader: GLTFLoader);
  1786. /** @hidden */
  1787. dispose(): void;
  1788. /** @hidden */
  1789. onLoading(): void;
  1790. /** @hidden */
  1791. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1792. }
  1793. }
  1794. declare module BABYLON.GLTF2.Loader.Extensions {
  1795. /**
  1796. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1797. */
  1798. class KHR_texture_transform implements IGLTFLoaderExtension {
  1799. /** The name of this extension. */
  1800. readonly name: string;
  1801. /** Defines whether this extension is enabled. */
  1802. enabled: boolean;
  1803. private _loader;
  1804. /** @hidden */
  1805. constructor(loader: GLTFLoader);
  1806. /** @hidden */
  1807. dispose(): void;
  1808. /** @hidden */
  1809. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1810. }
  1811. }
  1812. declare module BABYLON.GLTF2.Loader.Extensions {
  1813. /**
  1814. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1815. */
  1816. class EXT_lights_image_based implements IGLTFLoaderExtension {
  1817. /** The name of this extension. */
  1818. readonly name: string;
  1819. /** Defines whether this extension is enabled. */
  1820. enabled: boolean;
  1821. private _loader;
  1822. private _lights?;
  1823. /** @hidden */
  1824. constructor(loader: GLTFLoader);
  1825. /** @hidden */
  1826. dispose(): void;
  1827. /** @hidden */
  1828. onLoading(): void;
  1829. /** @hidden */
  1830. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1831. private _loadLightAsync;
  1832. }
  1833. }