babylonjs.loaders.module.d.ts 72 KB

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