babylonjs.loaders.d.ts 69 KB

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