babylonjs.loaders.module.d.ts 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858
  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 {BABYLON.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 {
  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 ILoaderAccessor extends 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 ILoaderAnimationChannel extends IAnimationChannel, IArrayItem {
  1054. }
  1055. /** @hidden */
  1056. interface _ILoaderAnimationSamplerData {
  1057. input: Float32Array;
  1058. interpolation: AnimationSamplerInterpolation;
  1059. output: Float32Array;
  1060. }
  1061. /**
  1062. * Loader interface with additional members.
  1063. */
  1064. interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem {
  1065. /** @hidden */
  1066. _data?: Promise<_ILoaderAnimationSamplerData>;
  1067. }
  1068. /**
  1069. * Loader interface with additional members.
  1070. */
  1071. interface ILoaderAnimation extends IAnimation, IArrayItem {
  1072. channels: ILoaderAnimationChannel[];
  1073. samplers: ILoaderAnimationSampler[];
  1074. /** @hidden */
  1075. _babylonAnimationGroup?: AnimationGroup;
  1076. }
  1077. /**
  1078. * Loader interface with additional members.
  1079. */
  1080. interface ILoaderBuffer extends IBuffer, IArrayItem {
  1081. /** @hidden */
  1082. _data?: Promise<ArrayBufferView>;
  1083. }
  1084. /**
  1085. * Loader interface with additional members.
  1086. */
  1087. interface ILoaderBufferView extends 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 ILoaderCamera extends ICamera, IArrayItem {
  1097. }
  1098. /**
  1099. * Loader interface with additional members.
  1100. */
  1101. interface ILoaderImage extends IImage, IArrayItem {
  1102. /** @hidden */
  1103. _data?: Promise<ArrayBufferView>;
  1104. }
  1105. /**
  1106. * Loader interface with additional members.
  1107. */
  1108. interface ILoaderMaterialNormalTextureInfo extends IMaterialNormalTextureInfo, ILoaderTextureInfo {
  1109. }
  1110. /**
  1111. * Loader interface with additional members.
  1112. */
  1113. interface ILoaderMaterialOcclusionTextureInfo extends IMaterialOcclusionTextureInfo, ILoaderTextureInfo {
  1114. }
  1115. /**
  1116. * Loader interface with additional members.
  1117. */
  1118. interface ILoaderMaterialPbrMetallicRoughness extends IMaterialPbrMetallicRoughness {
  1119. baseColorTexture?: ILoaderTextureInfo;
  1120. metallicRoughnessTexture?: ILoaderTextureInfo;
  1121. }
  1122. /**
  1123. * Loader interface with additional members.
  1124. */
  1125. interface ILoaderMaterial extends IMaterial, IArrayItem {
  1126. pbrMetallicRoughness?: ILoaderMaterialPbrMetallicRoughness;
  1127. normalTexture?: ILoaderMaterialNormalTextureInfo;
  1128. occlusionTexture?: ILoaderMaterialOcclusionTextureInfo;
  1129. emissiveTexture?: ILoaderTextureInfo;
  1130. /** @hidden */
  1131. _babylonData?: {
  1132. [drawMode: number]: {
  1133. material: Material;
  1134. meshes: AbstractMesh[];
  1135. promise: Promise<void>;
  1136. };
  1137. };
  1138. }
  1139. /**
  1140. * Loader interface with additional members.
  1141. */
  1142. interface ILoaderMesh extends IMesh, IArrayItem {
  1143. primitives: ILoaderMeshPrimitive[];
  1144. }
  1145. /**
  1146. * Loader interface with additional members.
  1147. */
  1148. interface ILoaderMeshPrimitive extends IMeshPrimitive, IArrayItem {
  1149. }
  1150. /**
  1151. * Loader interface with additional members.
  1152. */
  1153. interface ILoaderNode extends INode, IArrayItem {
  1154. /**
  1155. * The parent glTF node.
  1156. */
  1157. parent?: ILoaderNode;
  1158. /** @hidden */
  1159. _babylonMesh?: Mesh;
  1160. /** @hidden */
  1161. _primitiveBabylonMeshes?: Mesh[];
  1162. /** @hidden */
  1163. _babylonBones?: Bone[];
  1164. /** @hidden */
  1165. _numMorphTargets?: number;
  1166. }
  1167. /** @hidden */
  1168. interface _ILoaderSamplerData {
  1169. noMipMaps: boolean;
  1170. samplingMode: number;
  1171. wrapU: number;
  1172. wrapV: number;
  1173. }
  1174. /**
  1175. * Loader interface with additional members.
  1176. */
  1177. interface ILoaderSampler extends ISampler, IArrayItem {
  1178. /** @hidden */
  1179. _data?: _ILoaderSamplerData;
  1180. }
  1181. /**
  1182. * Loader interface with additional members.
  1183. */
  1184. interface ILoaderScene extends IScene, IArrayItem {
  1185. }
  1186. /**
  1187. * Loader interface with additional members.
  1188. */
  1189. interface ILoaderSkin extends ISkin, IArrayItem {
  1190. /** @hidden */
  1191. _babylonSkeleton?: Skeleton;
  1192. /** @hidden */
  1193. _promise?: Promise<void>;
  1194. }
  1195. /**
  1196. * Loader interface with additional members.
  1197. */
  1198. interface ILoaderTexture extends ITexture, IArrayItem {
  1199. }
  1200. /**
  1201. * Loader interface with additional members.
  1202. */
  1203. interface ILoaderTextureInfo extends ITextureInfo {
  1204. }
  1205. /**
  1206. * Loader interface with additional members.
  1207. */
  1208. interface ILoaderGLTF extends IGLTF {
  1209. accessors?: ILoaderAccessor[];
  1210. animations?: ILoaderAnimation[];
  1211. buffers?: ILoaderBuffer[];
  1212. bufferViews?: ILoaderBufferView[];
  1213. cameras?: ILoaderCamera[];
  1214. images?: ILoaderImage[];
  1215. materials?: ILoaderMaterial[];
  1216. meshes?: ILoaderMesh[];
  1217. nodes?: ILoaderNode[];
  1218. samplers?: ILoaderSampler[];
  1219. scenes?: ILoaderScene[];
  1220. skins?: ILoaderSkin[];
  1221. textures?: ILoaderTexture[];
  1222. }
  1223. }
  1224. /**
  1225. * Defines the module for importing and exporting glTF 2.0 assets
  1226. */
  1227. declare module BABYLON.GLTF2 {
  1228. /**
  1229. * Helper class for working with arrays when loading the glTF asset
  1230. */
  1231. class ArrayItem {
  1232. /**
  1233. * Gets an item from the given array.
  1234. * @param context The context when loading the asset
  1235. * @param array The array to get the item from
  1236. * @param index The index to the array
  1237. * @returns The array item
  1238. */
  1239. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1240. /**
  1241. * Assign an `index` field to each item of the given array.
  1242. * @param array The array of items
  1243. */
  1244. static Assign(array?: IArrayItem[]): void;
  1245. }
  1246. /**
  1247. * The glTF 2.0 loader
  1248. */
  1249. class GLTFLoader implements IGLTFLoader {
  1250. /** The glTF object parsed from the JSON. */
  1251. gltf: ILoaderGLTF;
  1252. /** The Babylon scene when loading the asset. */
  1253. babylonScene: Scene;
  1254. /** @hidden */
  1255. _completePromises: Promise<any>[];
  1256. private _disposed;
  1257. private _parent;
  1258. private _state;
  1259. private _extensions;
  1260. private _rootUrl;
  1261. private _fileName;
  1262. private _uniqueRootUrl;
  1263. private _rootBabylonMesh;
  1264. private _defaultBabylonMaterialData;
  1265. private _progressCallback?;
  1266. private _requests;
  1267. private static readonly _DefaultSampler;
  1268. private static _ExtensionNames;
  1269. private static _ExtensionFactories;
  1270. /**
  1271. * Registers a loader extension.
  1272. * @param name The name of the loader extension.
  1273. * @param factory The factory function that creates the loader extension.
  1274. */
  1275. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1276. /**
  1277. * Unregisters a loader extension.
  1278. * @param name The name of the loader extenion.
  1279. * @returns A boolean indicating whether the extension has been unregistered
  1280. */
  1281. static UnregisterExtension(name: string): boolean;
  1282. /**
  1283. * Gets the loader state.
  1284. */
  1285. readonly state: Nullable<GLTFLoaderState>;
  1286. /** @hidden */
  1287. constructor(parent: GLTFFileLoader);
  1288. /** @hidden */
  1289. dispose(): void;
  1290. /** @hidden */
  1291. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1292. meshes: AbstractMesh[];
  1293. particleSystems: IParticleSystem[];
  1294. skeletons: Skeleton[];
  1295. animationGroups: AnimationGroup[];
  1296. }>;
  1297. /** @hidden */
  1298. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1299. private _loadAsync;
  1300. private _loadData;
  1301. private _setupData;
  1302. private _loadExtensions;
  1303. private _checkExtensions;
  1304. private _setState;
  1305. private _createRootNode;
  1306. /**
  1307. * Loads a glTF scene.
  1308. * @param context The context when loading the asset
  1309. * @param scene The glTF scene property
  1310. * @returns A promise that resolves when the load is complete
  1311. */
  1312. loadSceneAsync(context: string, scene: ILoaderScene): Promise<void>;
  1313. private _forEachPrimitive;
  1314. private _getMeshes;
  1315. private _getSkeletons;
  1316. private _getAnimationGroups;
  1317. private _startAnimations;
  1318. /**
  1319. * Loads a glTF node.
  1320. * @param context The context when loading the asset
  1321. * @param node The glTF node property
  1322. * @param assign A function called synchronously after parsing the glTF properties
  1323. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1324. */
  1325. loadNodeAsync(context: string, node: ILoaderNode, assign?: (babylonMesh: Mesh) => void): Promise<Mesh>;
  1326. private _loadMeshAsync;
  1327. private _loadMeshPrimitiveAsync;
  1328. private _loadVertexDataAsync;
  1329. private _createMorphTargets;
  1330. private _loadMorphTargetsAsync;
  1331. private _loadMorphTargetVertexDataAsync;
  1332. private static _LoadTransform;
  1333. private _loadSkinAsync;
  1334. private _loadBones;
  1335. private _loadBone;
  1336. private _loadSkinInverseBindMatricesDataAsync;
  1337. private _updateBoneMatrices;
  1338. private _getNodeMatrix;
  1339. /**
  1340. * Loads a glTF camera.
  1341. * @param context The context when loading the asset
  1342. * @param camera The glTF camera property
  1343. * @param assign A function called synchronously after parsing the glTF properties
  1344. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1345. */
  1346. loadCameraAsync(context: string, camera: ILoaderCamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1347. private _loadAnimationsAsync;
  1348. /**
  1349. * Loads a glTF animation.
  1350. * @param context The context when loading the asset
  1351. * @param animation The glTF animation property
  1352. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1353. */
  1354. loadAnimationAsync(context: string, animation: ILoaderAnimation): Promise<AnimationGroup>;
  1355. private _loadAnimationChannelAsync;
  1356. private _loadAnimationSamplerAsync;
  1357. private _loadBufferAsync;
  1358. /**
  1359. * Loads a glTF buffer view.
  1360. * @param context The context when loading the asset
  1361. * @param bufferView The glTF buffer view property
  1362. * @returns A promise that resolves with the loaded data when the load is complete
  1363. */
  1364. loadBufferViewAsync(context: string, bufferView: ILoaderBufferView): Promise<ArrayBufferView>;
  1365. private _loadIndicesAccessorAsync;
  1366. private _loadFloatAccessorAsync;
  1367. private _loadVertexBufferViewAsync;
  1368. private _loadVertexAccessorAsync;
  1369. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1370. /** @hidden */
  1371. _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1372. private _createDefaultMaterial;
  1373. /**
  1374. * Creates a Babylon material from a glTF material.
  1375. * @param context The context when loading the asset
  1376. * @param material The glTF material property
  1377. * @param babylonDrawMode The draw mode for the Babylon material
  1378. * @returns The Babylon material
  1379. */
  1380. createMaterial(context: string, material: ILoaderMaterial, babylonDrawMode: number): Material;
  1381. /**
  1382. * Loads properties from a glTF material into a Babylon material.
  1383. * @param context The context when loading the asset
  1384. * @param material The glTF material property
  1385. * @param babylonMaterial The Babylon material
  1386. * @returns A promise that resolves when the load is complete
  1387. */
  1388. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Promise<void>;
  1389. /**
  1390. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1391. * @param context The context when loading the asset
  1392. * @param material The glTF material property
  1393. * @param babylonMaterial The Babylon material
  1394. * @returns A promise that resolves when the load is complete
  1395. */
  1396. loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Promise<void>;
  1397. /**
  1398. * Loads the alpha properties from a glTF material into a Babylon material.
  1399. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1400. * @param context The context when loading the asset
  1401. * @param material The glTF material property
  1402. * @param babylonMaterial The Babylon material
  1403. */
  1404. loadMaterialAlphaProperties(context: string, material: ILoaderMaterial, babylonMaterial: Material): void;
  1405. /**
  1406. * Loads a glTF texture info.
  1407. * @param context The context when loading the asset
  1408. * @param textureInfo The glTF texture info property
  1409. * @param assign A function called synchronously after parsing the glTF properties
  1410. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1411. */
  1412. loadTextureInfoAsync(context: string, textureInfo: ILoaderTextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1413. private _loadTextureAsync;
  1414. private _loadSampler;
  1415. /**
  1416. * Loads a glTF image.
  1417. * @param context The context when loading the asset
  1418. * @param image The glTF image property
  1419. * @returns A promise that resolves with the loaded data when the load is complete
  1420. */
  1421. loadImageAsync(context: string, image: ILoaderImage): Promise<ArrayBufferView>;
  1422. /**
  1423. * Loads a glTF uri.
  1424. * @param context The context when loading the asset
  1425. * @param uri The base64 or relative uri
  1426. * @returns A promise that resolves with the loaded data when the load is complete
  1427. */
  1428. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  1429. private _onProgress;
  1430. private static _GetTextureWrapMode;
  1431. private static _GetTextureSamplingMode;
  1432. private static _GetTypedArray;
  1433. private static _GetNumComponents;
  1434. private static _ValidateUri;
  1435. private static _GetDrawMode;
  1436. private _compileMaterialsAsync;
  1437. private _compileShadowGeneratorsAsync;
  1438. private _forEachExtensions;
  1439. private _applyExtensions;
  1440. private _extensionsOnLoading;
  1441. private _extensionsOnReady;
  1442. private _extensionsLoadSceneAsync;
  1443. private _extensionsLoadNodeAsync;
  1444. private _extensionsLoadCameraAsync;
  1445. private _extensionsLoadVertexDataAsync;
  1446. private _extensionsLoadMaterialAsync;
  1447. private _extensionsCreateMaterial;
  1448. private _extensionsLoadMaterialPropertiesAsync;
  1449. private _extensionsLoadTextureInfoAsync;
  1450. private _extensionsLoadAnimationAsync;
  1451. private _extensionsLoadUriAsync;
  1452. /**
  1453. * Helper method called by a loader extension to load an glTF extension.
  1454. * @param context The context when loading the asset
  1455. * @param property The glTF property to load the extension from
  1456. * @param extensionName The name of the extension to load
  1457. * @param actionAsync The action to run
  1458. * @returns The promise returned by actionAsync or null if the extension does not exist
  1459. */
  1460. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1461. /**
  1462. * Helper method called by a loader extension to load a glTF extra.
  1463. * @param context The context when loading the asset
  1464. * @param property The glTF property to load the extra from
  1465. * @param extensionName The name of the extension to load
  1466. * @param actionAsync The action to run
  1467. * @returns The promise returned by actionAsync or null if the extra does not exist
  1468. */
  1469. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1470. /**
  1471. * Increments the indentation level and logs a message.
  1472. * @param message The message to log
  1473. */
  1474. logOpen(message: string): void;
  1475. /**
  1476. * Decrements the indentation level.
  1477. */
  1478. logClose(): void;
  1479. /**
  1480. * Logs a message
  1481. * @param message The message to log
  1482. */
  1483. log(message: string): void;
  1484. /**
  1485. * Starts a performance counter.
  1486. * @param counterName The name of the performance counter
  1487. */
  1488. startPerformanceCounter(counterName: string): void;
  1489. /**
  1490. * Ends a performance counter.
  1491. * @param counterName The name of the performance counter
  1492. */
  1493. endPerformanceCounter(counterName: string): void;
  1494. }
  1495. }
  1496. declare module BABYLON.GLTF2 {
  1497. /**
  1498. * Interface for a glTF loader extension.
  1499. */
  1500. interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  1501. /**
  1502. * Called after the loader state changes to LOADING.
  1503. */
  1504. onLoading?(): void;
  1505. /**
  1506. * Called after the loader state changes to READY.
  1507. */
  1508. onReady?(): void;
  1509. /**
  1510. * Define this method to modify the default behavior when loading scenes.
  1511. * @param context The context when loading the asset
  1512. * @param scene The glTF scene property
  1513. * @returns A promise that resolves when the load is complete or null if not handled
  1514. */
  1515. loadSceneAsync?(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  1516. /**
  1517. * Define this method to modify the default behavior when loading nodes.
  1518. * @param context The context when loading the asset
  1519. * @param node The glTF node property
  1520. * @param assign A function called synchronously after parsing the glTF properties
  1521. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  1522. */
  1523. loadNodeAsync?(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1524. /**
  1525. * Define this method to modify the default behavior when loading cameras.
  1526. * @param context The context when loading the asset
  1527. * @param camera The glTF camera property
  1528. * @param assign A function called synchronously after parsing the glTF properties
  1529. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1530. */
  1531. loadCameraAsync?(context: string, camera: ILoaderCamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1532. /**
  1533. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1534. * @param context The context when loading the asset
  1535. * @param primitive The glTF mesh primitive property
  1536. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1537. */
  1538. _loadVertexDataAsync?(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1539. /**
  1540. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1541. * @param context The context when loading the asset
  1542. * @param material The glTF material property
  1543. * @param assign A function called synchronously after parsing the glTF properties
  1544. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1545. */
  1546. _loadMaterialAsync?(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1547. /**
  1548. * Define this method to modify the default behavior when creating materials.
  1549. * @param context The context when loading the asset
  1550. * @param material The glTF material property
  1551. * @param babylonDrawMode The draw mode for the Babylon material
  1552. * @returns The Babylon material or null if not handled
  1553. */
  1554. createMaterial?(context: string, material: ILoaderMaterial, babylonDrawMode: number): Nullable<Material>;
  1555. /**
  1556. * Define this method to modify the default behavior when loading material properties.
  1557. * @param context The context when loading the asset
  1558. * @param material The glTF material property
  1559. * @param babylonMaterial The Babylon material
  1560. * @returns A promise that resolves when the load is complete or null if not handled
  1561. */
  1562. loadMaterialPropertiesAsync?(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1563. /**
  1564. * Define this method to modify the default behavior when loading texture infos.
  1565. * @param context The context when loading the asset
  1566. * @param textureInfo The glTF texture info property
  1567. * @param assign A function called synchronously after parsing the glTF properties
  1568. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1569. */
  1570. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1571. /**
  1572. * Define this method to modify the default behavior when loading animations.
  1573. * @param context The context when loading the asset
  1574. * @param animation The glTF animation property
  1575. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1576. */
  1577. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1578. /**
  1579. * Define this method to modify the default behavior when loading uris.
  1580. * @param context The context when loading the asset
  1581. * @param uri The uri to load
  1582. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1583. */
  1584. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1585. }
  1586. }
  1587. /**
  1588. * Defines the module for the built-in glTF 2.0 loader extensions.
  1589. */
  1590. declare module BABYLON.GLTF2.Extensions {
  1591. }
  1592. declare module BABYLON.GLTF2.Extensions {
  1593. /**
  1594. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1595. */
  1596. class MSFT_lod implements IGLTFLoaderExtension {
  1597. /** The name of this extension. */
  1598. readonly name: string;
  1599. /** Defines whether this extension is enabled. */
  1600. enabled: boolean;
  1601. /**
  1602. * Maximum number of LODs to load, starting from the lowest LOD.
  1603. */
  1604. maxLODsToLoad: number;
  1605. /**
  1606. * Observable raised when all node LODs of one level are loaded.
  1607. * The event data is the index of the loaded LOD starting from zero.
  1608. * Dispose the loader to cancel the loading of the next level of LODs.
  1609. */
  1610. onNodeLODsLoadedObservable: Observable<number>;
  1611. /**
  1612. * Observable raised when all material 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. onMaterialLODsLoadedObservable: Observable<number>;
  1617. private _loader;
  1618. private _nodeIndexLOD;
  1619. private _nodeSignalLODs;
  1620. private _nodePromiseLODs;
  1621. private _materialIndexLOD;
  1622. private _materialSignalLODs;
  1623. private _materialPromiseLODs;
  1624. /** @hidden */
  1625. constructor(loader: GLTFLoader);
  1626. /** @hidden */
  1627. dispose(): void;
  1628. /** @hidden */
  1629. onReady(): void;
  1630. /** @hidden */
  1631. loadNodeAsync(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1632. /** @hidden */
  1633. _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1634. /** @hidden */
  1635. _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1636. /**
  1637. * Gets an array of LOD properties from lowest to highest.
  1638. */
  1639. private _getLODs;
  1640. private _disposeUnusedMaterials;
  1641. }
  1642. }
  1643. declare module BABYLON.GLTF2.Extensions {
  1644. /** @hidden */
  1645. class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1646. readonly name: string;
  1647. enabled: boolean;
  1648. private _loader;
  1649. constructor(loader: GLTFLoader);
  1650. dispose(): void;
  1651. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1652. }
  1653. }
  1654. declare module BABYLON.GLTF2.Extensions {
  1655. /** @hidden */
  1656. class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1657. readonly name: string;
  1658. enabled: boolean;
  1659. private _loader;
  1660. constructor(loader: GLTFLoader);
  1661. dispose(): void;
  1662. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1663. }
  1664. }
  1665. declare module BABYLON.GLTF2.Extensions {
  1666. /**
  1667. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1668. */
  1669. class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1670. /** The name of this extension. */
  1671. readonly name: string;
  1672. /** Defines whether this extension is enabled. */
  1673. enabled: boolean;
  1674. private _loader;
  1675. private _clips;
  1676. private _emitters;
  1677. /** @hidden */
  1678. constructor(loader: GLTFLoader);
  1679. /** @hidden */
  1680. dispose(): void;
  1681. /** @hidden */
  1682. onLoading(): void;
  1683. /** @hidden */
  1684. loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  1685. /** @hidden */
  1686. loadNodeAsync(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1687. /** @hidden */
  1688. loadAnimationAsync(context: string, animation: ILoaderAnimation): Nullable<Promise<AnimationGroup>>;
  1689. private _loadClipAsync;
  1690. private _loadEmitterAsync;
  1691. private _getEventAction;
  1692. private _loadAnimationEventAsync;
  1693. }
  1694. }
  1695. declare module BABYLON.GLTF2.Extensions {
  1696. /**
  1697. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1698. */
  1699. class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1700. /** The name of this extension. */
  1701. readonly name: string;
  1702. /** Defines whether this extension is enabled. */
  1703. enabled: boolean;
  1704. private _loader;
  1705. private _dracoCompression?;
  1706. /** @hidden */
  1707. constructor(loader: GLTFLoader);
  1708. /** @hidden */
  1709. dispose(): void;
  1710. /** @hidden */
  1711. _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1712. }
  1713. }
  1714. declare module BABYLON.GLTF2.Extensions {
  1715. /**
  1716. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1717. */
  1718. class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1719. /** The name of this extension. */
  1720. readonly name: string;
  1721. /** Defines whether this extension is enabled. */
  1722. enabled: boolean;
  1723. private _loader;
  1724. /** @hidden */
  1725. constructor(loader: GLTFLoader);
  1726. /** @hidden */
  1727. dispose(): void;
  1728. /** @hidden */
  1729. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1730. private _loadSpecularGlossinessPropertiesAsync;
  1731. }
  1732. }
  1733. declare module BABYLON.GLTF2.Extensions {
  1734. /**
  1735. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1736. */
  1737. class KHR_materials_unlit implements IGLTFLoaderExtension {
  1738. /** The name of this extension. */
  1739. readonly name: string;
  1740. /** Defines whether this extension is enabled. */
  1741. enabled: boolean;
  1742. private _loader;
  1743. /** @hidden */
  1744. constructor(loader: GLTFLoader);
  1745. /** @hidden */
  1746. dispose(): void;
  1747. /** @hidden */
  1748. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1749. private _loadUnlitPropertiesAsync;
  1750. }
  1751. }
  1752. declare module BABYLON.GLTF2.Extensions {
  1753. /**
  1754. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1755. */
  1756. class KHR_lights implements IGLTFLoaderExtension {
  1757. /** The name of this extension. */
  1758. readonly name: string;
  1759. /** Defines whether this extension is enabled. */
  1760. enabled: boolean;
  1761. private _loader;
  1762. private _lights?;
  1763. /** @hidden */
  1764. constructor(loader: GLTFLoader);
  1765. /** @hidden */
  1766. dispose(): void;
  1767. /** @hidden */
  1768. onLoading(): void;
  1769. /** @hidden */
  1770. loadNodeAsync(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1771. }
  1772. }
  1773. declare module BABYLON.GLTF2.Extensions {
  1774. /**
  1775. * [Specification](https://github.com/AltspaceVR/glTF/blob/avr-sampler-offset-tile/extensions/2.0/Khronos/KHR_texture_transform/README.md) (Experimental)
  1776. */
  1777. class KHR_texture_transform implements IGLTFLoaderExtension {
  1778. /** The name of this extension. */
  1779. readonly name: string;
  1780. /** Defines whether this extension is enabled. */
  1781. enabled: boolean;
  1782. private _loader;
  1783. /** @hidden */
  1784. constructor(loader: GLTFLoader);
  1785. /** @hidden */
  1786. dispose(): void;
  1787. /** @hidden */
  1788. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1789. }
  1790. }
  1791. declare module BABYLON.GLTF2.Extensions {
  1792. /**
  1793. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1794. */
  1795. class EXT_lights_image_based implements IGLTFLoaderExtension {
  1796. /** The name of this extension. */
  1797. readonly name: string;
  1798. /** Defines whether this extension is enabled. */
  1799. enabled: boolean;
  1800. private _loader;
  1801. private _lights?;
  1802. /** @hidden */
  1803. constructor(loader: GLTFLoader);
  1804. /** @hidden */
  1805. dispose(): void;
  1806. /** @hidden */
  1807. onLoading(): void;
  1808. /** @hidden */
  1809. loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  1810. private _loadLightAsync;
  1811. }
  1812. }