babylonjs.loaders.d.ts 72 KB

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