babylonjs.loaders.module.d.ts 69 KB

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