babylonjs.loaders.d.ts 71 KB

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