babylonjs.loaders.d.ts 71 KB

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