babylonjs.loaders.module.d.ts 71 KB

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