babylonjs.loaders.module.d.ts 71 KB

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