babylonjs.loaders.module.d.ts 71 KB

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