babylonjs.loaders.d.ts 71 KB

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