babylonjs.loaders.module.d.ts 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872
  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. /**
  1437. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1438. * @param babylonObject the Babylon object with metadata
  1439. * @param pointer the JSON pointer
  1440. */
  1441. static AddPointerMetadata(babylonObject: {
  1442. metadata: any;
  1443. }, pointer: string): void;
  1444. private static _GetTextureWrapMode;
  1445. private static _GetTextureSamplingMode;
  1446. private static _GetTypedArray;
  1447. private static _GetNumComponents;
  1448. private static _ValidateUri;
  1449. private static _GetDrawMode;
  1450. private _compileMaterialsAsync;
  1451. private _compileShadowGeneratorsAsync;
  1452. private _forEachExtensions;
  1453. private _applyExtensions;
  1454. private _extensionsOnLoading;
  1455. private _extensionsOnReady;
  1456. private _extensionsLoadSceneAsync;
  1457. private _extensionsLoadNodeAsync;
  1458. private _extensionsLoadCameraAsync;
  1459. private _extensionsLoadVertexDataAsync;
  1460. private _extensionsLoadMaterialAsync;
  1461. private _extensionsCreateMaterial;
  1462. private _extensionsLoadMaterialPropertiesAsync;
  1463. private _extensionsLoadTextureInfoAsync;
  1464. private _extensionsLoadAnimationAsync;
  1465. private _extensionsLoadUriAsync;
  1466. /**
  1467. * Helper method called by a loader extension to load an glTF extension.
  1468. * @param context The context when loading the asset
  1469. * @param property The glTF property to load the extension from
  1470. * @param extensionName The name of the extension to load
  1471. * @param actionAsync The action to run
  1472. * @returns The promise returned by actionAsync or null if the extension does not exist
  1473. */
  1474. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1475. /**
  1476. * Helper method called by a loader extension to load a glTF extra.
  1477. * @param context The context when loading the asset
  1478. * @param property The glTF property to load the extra from
  1479. * @param extensionName The name of the extension to load
  1480. * @param actionAsync The action to run
  1481. * @returns The promise returned by actionAsync or null if the extra does not exist
  1482. */
  1483. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1484. /**
  1485. * Increments the indentation level and logs a message.
  1486. * @param message The message to log
  1487. */
  1488. logOpen(message: string): void;
  1489. /**
  1490. * Decrements the indentation level.
  1491. */
  1492. logClose(): void;
  1493. /**
  1494. * Logs a message
  1495. * @param message The message to log
  1496. */
  1497. log(message: string): void;
  1498. /**
  1499. * Starts a performance counter.
  1500. * @param counterName The name of the performance counter
  1501. */
  1502. startPerformanceCounter(counterName: string): void;
  1503. /**
  1504. * Ends a performance counter.
  1505. * @param counterName The name of the performance counter
  1506. */
  1507. endPerformanceCounter(counterName: string): void;
  1508. }
  1509. }
  1510. declare module BABYLON.GLTF2 {
  1511. /**
  1512. * Interface for a glTF loader extension.
  1513. */
  1514. interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  1515. /**
  1516. * Called after the loader state changes to LOADING.
  1517. */
  1518. onLoading?(): void;
  1519. /**
  1520. * Called after the loader state changes to READY.
  1521. */
  1522. onReady?(): void;
  1523. /**
  1524. * Define this method to modify the default behavior when loading scenes.
  1525. * @param context The context when loading the asset
  1526. * @param scene The glTF scene property
  1527. * @returns A promise that resolves when the load is complete or null if not handled
  1528. */
  1529. loadSceneAsync?(context: string, scene: Loader.IScene): Nullable<Promise<void>>;
  1530. /**
  1531. * Define this method to modify the default behavior when loading nodes.
  1532. * @param context The context when loading the asset
  1533. * @param node The glTF node property
  1534. * @param assign A function called synchronously after parsing the glTF properties
  1535. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1536. */
  1537. loadNodeAsync?(context: string, node: Loader.INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1538. /**
  1539. * Define this method to modify the default behavior when loading cameras.
  1540. * @param context The context when loading the asset
  1541. * @param camera The glTF camera property
  1542. * @param assign A function called synchronously after parsing the glTF properties
  1543. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1544. */
  1545. loadCameraAsync?(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1546. /**
  1547. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1548. * @param context The context when loading the asset
  1549. * @param primitive The glTF mesh primitive property
  1550. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1551. */
  1552. _loadVertexDataAsync?(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1553. /**
  1554. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1555. * @param context The context when loading the asset
  1556. * @param material The glTF material property
  1557. * @param assign A function called synchronously after parsing the glTF properties
  1558. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1559. */
  1560. _loadMaterialAsync?(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1561. /**
  1562. * Define this method to modify the default behavior when creating materials.
  1563. * @param context The context when loading the asset
  1564. * @param material The glTF material property
  1565. * @param babylonDrawMode The draw mode for the Babylon material
  1566. * @returns The Babylon material or null if not handled
  1567. */
  1568. createMaterial?(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material>;
  1569. /**
  1570. * Define this method to modify the default behavior when loading material properties.
  1571. * @param context The context when loading the asset
  1572. * @param material The glTF material property
  1573. * @param babylonMaterial The Babylon material
  1574. * @returns A promise that resolves when the load is complete or null if not handled
  1575. */
  1576. loadMaterialPropertiesAsync?(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1577. /**
  1578. * Define this method to modify the default behavior when loading texture infos.
  1579. * @param context The context when loading the asset
  1580. * @param textureInfo The glTF texture info property
  1581. * @param assign A function called synchronously after parsing the glTF properties
  1582. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1583. */
  1584. loadTextureInfoAsync?(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1585. /**
  1586. * Define this method to modify the default behavior when loading animations.
  1587. * @param context The context when loading the asset
  1588. * @param animation The glTF animation property
  1589. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1590. */
  1591. loadAnimationAsync?(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>>;
  1592. /**
  1593. * Define this method to modify the default behavior when loading uris.
  1594. * @param context The context when loading the asset
  1595. * @param uri The uri to load
  1596. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1597. */
  1598. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1599. }
  1600. }
  1601. /**
  1602. * Defines the module for the built-in glTF 2.0 loader extensions.
  1603. */
  1604. declare module BABYLON.GLTF2.Loader.Extensions {
  1605. }
  1606. declare module BABYLON.GLTF2.Loader.Extensions {
  1607. /**
  1608. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1609. */
  1610. class MSFT_lod implements IGLTFLoaderExtension {
  1611. /** The name of this extension. */
  1612. readonly name: string;
  1613. /** Defines whether this extension is enabled. */
  1614. enabled: boolean;
  1615. /**
  1616. * Maximum number of LODs to load, starting from the lowest LOD.
  1617. */
  1618. maxLODsToLoad: number;
  1619. /**
  1620. * Observable raised when all node LODs of one level are loaded.
  1621. * The event data is the index of the loaded LOD starting from zero.
  1622. * Dispose the loader to cancel the loading of the next level of LODs.
  1623. */
  1624. onNodeLODsLoadedObservable: Observable<number>;
  1625. /**
  1626. * Observable raised when all material LODs of one level are loaded.
  1627. * The event data is the index of the loaded LOD starting from zero.
  1628. * Dispose the loader to cancel the loading of the next level of LODs.
  1629. */
  1630. onMaterialLODsLoadedObservable: Observable<number>;
  1631. private _loader;
  1632. private _nodeIndexLOD;
  1633. private _nodeSignalLODs;
  1634. private _nodePromiseLODs;
  1635. private _materialIndexLOD;
  1636. private _materialSignalLODs;
  1637. private _materialPromiseLODs;
  1638. /** @hidden */
  1639. constructor(loader: GLTFLoader);
  1640. /** @hidden */
  1641. dispose(): void;
  1642. /** @hidden */
  1643. onReady(): void;
  1644. /** @hidden */
  1645. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1646. /** @hidden */
  1647. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1648. /** @hidden */
  1649. _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1650. /**
  1651. * Gets an array of LOD properties from lowest to highest.
  1652. */
  1653. private _getLODs;
  1654. private _disposeUnusedMaterials;
  1655. }
  1656. }
  1657. declare module BABYLON.GLTF2.Loader.Extensions {
  1658. /** @hidden */
  1659. class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1660. readonly name: string;
  1661. enabled: boolean;
  1662. private _loader;
  1663. constructor(loader: GLTFLoader);
  1664. dispose(): void;
  1665. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1666. }
  1667. }
  1668. declare module BABYLON.GLTF2.Loader.Extensions {
  1669. /** @hidden */
  1670. class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1671. readonly name: string;
  1672. enabled: boolean;
  1673. private _loader;
  1674. constructor(loader: GLTFLoader);
  1675. dispose(): void;
  1676. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1677. }
  1678. }
  1679. declare module BABYLON.GLTF2.Loader.Extensions {
  1680. /**
  1681. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1682. */
  1683. class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1684. /** The name of this extension. */
  1685. readonly name: string;
  1686. /** Defines whether this extension is enabled. */
  1687. enabled: boolean;
  1688. private _loader;
  1689. private _clips;
  1690. private _emitters;
  1691. /** @hidden */
  1692. constructor(loader: GLTFLoader);
  1693. /** @hidden */
  1694. dispose(): void;
  1695. /** @hidden */
  1696. onLoading(): void;
  1697. /** @hidden */
  1698. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1699. /** @hidden */
  1700. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1701. /** @hidden */
  1702. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1703. private _loadClipAsync;
  1704. private _loadEmitterAsync;
  1705. private _getEventAction;
  1706. private _loadAnimationEventAsync;
  1707. }
  1708. }
  1709. declare module BABYLON.GLTF2.Loader.Extensions {
  1710. /**
  1711. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1712. */
  1713. class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1714. /** The name of this extension. */
  1715. readonly name: string;
  1716. /** Defines whether this extension is enabled. */
  1717. enabled: boolean;
  1718. private _loader;
  1719. private _dracoCompression?;
  1720. /** @hidden */
  1721. constructor(loader: GLTFLoader);
  1722. /** @hidden */
  1723. dispose(): void;
  1724. /** @hidden */
  1725. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1726. }
  1727. }
  1728. declare module BABYLON.GLTF2.Loader.Extensions {
  1729. /**
  1730. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1731. */
  1732. class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1733. /** The name of this extension. */
  1734. readonly name: string;
  1735. /** Defines whether this extension is enabled. */
  1736. enabled: boolean;
  1737. private _loader;
  1738. /** @hidden */
  1739. constructor(loader: GLTFLoader);
  1740. /** @hidden */
  1741. dispose(): void;
  1742. /** @hidden */
  1743. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1744. private _loadSpecularGlossinessPropertiesAsync;
  1745. }
  1746. }
  1747. declare module BABYLON.GLTF2.Loader.Extensions {
  1748. /**
  1749. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1750. */
  1751. class KHR_materials_unlit implements IGLTFLoaderExtension {
  1752. /** The name of this extension. */
  1753. readonly name: string;
  1754. /** Defines whether this extension is enabled. */
  1755. enabled: boolean;
  1756. private _loader;
  1757. /** @hidden */
  1758. constructor(loader: GLTFLoader);
  1759. /** @hidden */
  1760. dispose(): void;
  1761. /** @hidden */
  1762. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1763. private _loadUnlitPropertiesAsync;
  1764. }
  1765. }
  1766. declare module BABYLON.GLTF2.Loader.Extensions {
  1767. /**
  1768. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1769. */
  1770. class KHR_lights implements IGLTFLoaderExtension {
  1771. /** The name of this extension. */
  1772. readonly name: string;
  1773. /** Defines whether this extension is enabled. */
  1774. enabled: boolean;
  1775. private _loader;
  1776. private _lights?;
  1777. /** @hidden */
  1778. constructor(loader: GLTFLoader);
  1779. /** @hidden */
  1780. dispose(): void;
  1781. /** @hidden */
  1782. onLoading(): void;
  1783. /** @hidden */
  1784. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1785. }
  1786. }
  1787. declare module BABYLON.GLTF2.Loader.Extensions {
  1788. /**
  1789. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1790. */
  1791. class KHR_texture_transform implements IGLTFLoaderExtension {
  1792. /** The name of this extension. */
  1793. readonly name: string;
  1794. /** Defines whether this extension is enabled. */
  1795. enabled: boolean;
  1796. private _loader;
  1797. /** @hidden */
  1798. constructor(loader: GLTFLoader);
  1799. /** @hidden */
  1800. dispose(): void;
  1801. /** @hidden */
  1802. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1803. }
  1804. }
  1805. declare module BABYLON.GLTF2.Loader.Extensions {
  1806. /**
  1807. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1808. */
  1809. class EXT_lights_image_based implements IGLTFLoaderExtension {
  1810. /** The name of this extension. */
  1811. readonly name: string;
  1812. /** Defines whether this extension is enabled. */
  1813. enabled: boolean;
  1814. private _loader;
  1815. private _lights?;
  1816. /** @hidden */
  1817. constructor(loader: GLTFLoader);
  1818. /** @hidden */
  1819. dispose(): void;
  1820. /** @hidden */
  1821. onLoading(): void;
  1822. /** @hidden */
  1823. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1824. private _loadLightAsync;
  1825. }
  1826. }