babylonjs.loaders.d.ts 77 KB

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