babylonjs.loaders.module.d.ts 72 KB

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