babylonjs.loaders.d.ts 71 KB

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