babylonjs.loaders.module.d.ts 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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<ParticleSystem[]>, 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(data);
  18. private parseBinary(mesh, data);
  19. private parseASCII(mesh, solidData);
  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(rootUrl, value, scene);
  50. }
  51. class OBJFileLoader implements ISceneLoaderPlugin {
  52. static OPTIMIZE_WITH_UV: boolean;
  53. name: string;
  54. extensions: string;
  55. obj: RegExp;
  56. group: RegExp;
  57. mtllib: RegExp;
  58. usemtl: RegExp;
  59. smooth: RegExp;
  60. vertexPattern: RegExp;
  61. normalPattern: RegExp;
  62. uvPattern: RegExp;
  63. facePattern1: RegExp;
  64. facePattern2: RegExp;
  65. facePattern3: RegExp;
  66. facePattern4: RegExp;
  67. /**
  68. * Calls synchronously the MTL file attached to this obj.
  69. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70. * Without this function materials are not displayed in the first frame (but displayed after).
  71. * In consequence it is impossible to get material information in your HTML file
  72. *
  73. * @param url The URL of the MTL file
  74. * @param rootUrl
  75. * @param onSuccess Callback function to be called when the MTL file is loaded
  76. * @private
  77. */
  78. private _loadMTL(url, rootUrl, onSuccess);
  79. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80. load(scene: Scene, data: string, rootUrl: string): boolean;
  81. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82. /**
  83. * Read the OBJ file and create an Array of meshes.
  84. * Each mesh contains all information given by the OBJ and the MTL file.
  85. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  86. *
  87. * @param meshesNames
  88. * @param scene BABYLON.Scene The scene where are displayed the data
  89. * @param data String The content of the obj file
  90. * @param rootUrl String The path to the folder
  91. * @returns Array<AbstractMesh>
  92. * @private
  93. */
  94. private _parseSolid(meshesNames, scene, data, rootUrl);
  95. }
  96. }
  97. declare module BABYLON {
  98. enum GLTFLoaderCoordinateSystemMode {
  99. /**
  100. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  101. */
  102. AUTO = 0,
  103. /**
  104. * Sets the useRightHandedSystem flag on the scene.
  105. */
  106. FORCE_RIGHT_HANDED = 1,
  107. }
  108. enum GLTFLoaderAnimationStartMode {
  109. /**
  110. * No animation will start.
  111. */
  112. NONE = 0,
  113. /**
  114. * The first animation will start.
  115. */
  116. FIRST = 1,
  117. /**
  118. * All animations will start.
  119. */
  120. ALL = 2,
  121. }
  122. interface IGLTFLoaderData {
  123. json: Object;
  124. bin: Nullable<ArrayBufferView>;
  125. }
  126. interface IGLTFLoaderExtension {
  127. /**
  128. * The name of this extension.
  129. */
  130. readonly name: string;
  131. /**
  132. * Whether this extension is enabled.
  133. */
  134. enabled: boolean;
  135. }
  136. enum GLTFLoaderState {
  137. Loading = 0,
  138. Ready = 1,
  139. Complete = 2,
  140. }
  141. interface IGLTFLoader extends IDisposable {
  142. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  143. animationStartMode: GLTFLoaderAnimationStartMode;
  144. compileMaterials: boolean;
  145. useClipPlane: boolean;
  146. compileShadowGenerators: boolean;
  147. onMeshLoadedObservable: Observable<AbstractMesh>;
  148. onTextureLoadedObservable: Observable<BaseTexture>;
  149. onMaterialLoadedObservable: Observable<Material>;
  150. onAnimationGroupLoadedObservable: Observable<AnimationGroup>;
  151. onCompleteObservable: Observable<IGLTFLoader>;
  152. onDisposeObservable: Observable<IGLTFLoader>;
  153. onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  154. state: Nullable<GLTFLoaderState>;
  155. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{
  156. meshes: AbstractMesh[];
  157. particleSystems: ParticleSystem[];
  158. skeletons: Skeleton[];
  159. }>;
  160. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<void>;
  161. }
  162. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  163. static CreateGLTFLoaderV1: () => IGLTFLoader;
  164. static CreateGLTFLoaderV2: () => IGLTFLoader;
  165. /**
  166. * Raised when the asset has been parsed.
  167. * The data.json property stores the glTF JSON.
  168. * The data.bin property stores the BIN chunk from a glTF binary or null if the input is not a glTF binary.
  169. */
  170. onParsedObservable: Observable<IGLTFLoaderData>;
  171. private _onParsedObserver;
  172. onParsed: (loaderData: IGLTFLoaderData) => void;
  173. static IncrementalLoading: boolean;
  174. static HomogeneousCoordinates: boolean;
  175. /**
  176. * The coordinate system mode (AUTO, FORCE_RIGHT_HANDED).
  177. */
  178. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  179. /**
  180. * The animation start mode (NONE, FIRST, ALL).
  181. */
  182. animationStartMode: GLTFLoaderAnimationStartMode;
  183. /**
  184. * Set to true to compile materials before raising the success callback.
  185. */
  186. compileMaterials: boolean;
  187. /**
  188. * Set to true to also compile materials with clip planes.
  189. */
  190. useClipPlane: boolean;
  191. /**
  192. * Set to true to compile shadow generators before raising the success callback.
  193. */
  194. compileShadowGenerators: boolean;
  195. /**
  196. * Raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  197. */
  198. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  199. private _onMeshLoadedObserver;
  200. onMeshLoaded: (mesh: AbstractMesh) => void;
  201. /**
  202. * Raised when the loader creates a texture after parsing the glTF properties of the texture.
  203. */
  204. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  205. private _onTextureLoadedObserver;
  206. onTextureLoaded: (texture: BaseTexture) => void;
  207. /**
  208. * Raised when the loader creates a material after parsing the glTF properties of the material.
  209. */
  210. readonly onMaterialLoadedObservable: Observable<Material>;
  211. private _onMaterialLoadedObserver;
  212. onMaterialLoaded: (material: Material) => void;
  213. /**
  214. * Raised when the loader creates an animation group after parsing the glTF properties of the animation.
  215. */
  216. readonly onAnimationGroupLoadedObservable: Observable<AnimationGroup>;
  217. private _onAnimationGroupLoadedObserver;
  218. onAnimationGroupLoaded: (animationGroup: AnimationGroup) => void;
  219. /**
  220. * Raised when the asset is completely loaded, immediately before the loader is disposed.
  221. * For assets with LODs, raised when all of the LODs are complete.
  222. * For assets without LODs, raised when the model is complete, immediately after onSuccess.
  223. */
  224. readonly onCompleteObservable: Observable<GLTFFileLoader>;
  225. private _onCompleteObserver;
  226. onComplete: () => void;
  227. /**
  228. * Raised when the loader is disposed.
  229. */
  230. readonly onDisposeObservable: Observable<GLTFFileLoader>;
  231. private _onDisposeObserver;
  232. onDispose: () => void;
  233. /**
  234. * Raised after a loader extension is created.
  235. * Set additional options for a loader extension in this event.
  236. */
  237. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  238. private _onExtensionLoadedObserver;
  239. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  240. /**
  241. * Gets a promise that resolves when the asset is completely loaded.
  242. * @returns A promise that resolves when the asset is completely loaded.
  243. */
  244. whenCompleteAsync(): Promise<void>;
  245. /**
  246. * The loader state or null if not active.
  247. */
  248. readonly loaderState: Nullable<GLTFLoaderState>;
  249. private _loader;
  250. name: string;
  251. extensions: ISceneLoaderPluginExtensions;
  252. /**
  253. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  254. */
  255. dispose(): void;
  256. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  257. meshes: AbstractMesh[];
  258. particleSystems: ParticleSystem[];
  259. skeletons: Skeleton[];
  260. }>;
  261. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  262. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  263. canDirectLoad(data: string): boolean;
  264. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  265. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  266. private _parse(data);
  267. private _getLoader(loaderData);
  268. private static _parseBinary(data);
  269. private static _parseV1(binaryReader);
  270. private static _parseV2(binaryReader);
  271. private static _parseVersion(version);
  272. private static _compareVersion(a, b);
  273. private static _decodeBufferToText(buffer);
  274. }
  275. }
  276. declare module BABYLON.GLTF1 {
  277. /**
  278. * Enums
  279. */
  280. enum EComponentType {
  281. BYTE = 5120,
  282. UNSIGNED_BYTE = 5121,
  283. SHORT = 5122,
  284. UNSIGNED_SHORT = 5123,
  285. FLOAT = 5126,
  286. }
  287. enum EShaderType {
  288. FRAGMENT = 35632,
  289. VERTEX = 35633,
  290. }
  291. enum EParameterType {
  292. BYTE = 5120,
  293. UNSIGNED_BYTE = 5121,
  294. SHORT = 5122,
  295. UNSIGNED_SHORT = 5123,
  296. INT = 5124,
  297. UNSIGNED_INT = 5125,
  298. FLOAT = 5126,
  299. FLOAT_VEC2 = 35664,
  300. FLOAT_VEC3 = 35665,
  301. FLOAT_VEC4 = 35666,
  302. INT_VEC2 = 35667,
  303. INT_VEC3 = 35668,
  304. INT_VEC4 = 35669,
  305. BOOL = 35670,
  306. BOOL_VEC2 = 35671,
  307. BOOL_VEC3 = 35672,
  308. BOOL_VEC4 = 35673,
  309. FLOAT_MAT2 = 35674,
  310. FLOAT_MAT3 = 35675,
  311. FLOAT_MAT4 = 35676,
  312. SAMPLER_2D = 35678,
  313. }
  314. enum ETextureWrapMode {
  315. CLAMP_TO_EDGE = 33071,
  316. MIRRORED_REPEAT = 33648,
  317. REPEAT = 10497,
  318. }
  319. enum ETextureFilterType {
  320. NEAREST = 9728,
  321. LINEAR = 9728,
  322. NEAREST_MIPMAP_NEAREST = 9984,
  323. LINEAR_MIPMAP_NEAREST = 9985,
  324. NEAREST_MIPMAP_LINEAR = 9986,
  325. LINEAR_MIPMAP_LINEAR = 9987,
  326. }
  327. enum ETextureFormat {
  328. ALPHA = 6406,
  329. RGB = 6407,
  330. RGBA = 6408,
  331. LUMINANCE = 6409,
  332. LUMINANCE_ALPHA = 6410,
  333. }
  334. enum ECullingType {
  335. FRONT = 1028,
  336. BACK = 1029,
  337. FRONT_AND_BACK = 1032,
  338. }
  339. enum EBlendingFunction {
  340. ZERO = 0,
  341. ONE = 1,
  342. SRC_COLOR = 768,
  343. ONE_MINUS_SRC_COLOR = 769,
  344. DST_COLOR = 774,
  345. ONE_MINUS_DST_COLOR = 775,
  346. SRC_ALPHA = 770,
  347. ONE_MINUS_SRC_ALPHA = 771,
  348. DST_ALPHA = 772,
  349. ONE_MINUS_DST_ALPHA = 773,
  350. CONSTANT_COLOR = 32769,
  351. ONE_MINUS_CONSTANT_COLOR = 32770,
  352. CONSTANT_ALPHA = 32771,
  353. ONE_MINUS_CONSTANT_ALPHA = 32772,
  354. SRC_ALPHA_SATURATE = 776,
  355. }
  356. /**
  357. * Interfaces
  358. */
  359. interface IGLTFProperty {
  360. extensions?: {
  361. [key: string]: any;
  362. };
  363. extras?: Object;
  364. }
  365. interface IGLTFChildRootProperty extends IGLTFProperty {
  366. name?: string;
  367. }
  368. interface IGLTFAccessor extends IGLTFChildRootProperty {
  369. bufferView: string;
  370. byteOffset: number;
  371. byteStride: number;
  372. count: number;
  373. type: string;
  374. componentType: EComponentType;
  375. max?: number[];
  376. min?: number[];
  377. name?: string;
  378. }
  379. interface IGLTFBufferView extends IGLTFChildRootProperty {
  380. buffer: string;
  381. byteOffset: number;
  382. byteLength: number;
  383. byteStride: number;
  384. target?: number;
  385. }
  386. interface IGLTFBuffer extends IGLTFChildRootProperty {
  387. uri: string;
  388. byteLength?: number;
  389. type?: string;
  390. }
  391. interface IGLTFShader extends IGLTFChildRootProperty {
  392. uri: string;
  393. type: EShaderType;
  394. }
  395. interface IGLTFProgram extends IGLTFChildRootProperty {
  396. attributes: string[];
  397. fragmentShader: string;
  398. vertexShader: string;
  399. }
  400. interface IGLTFTechniqueParameter {
  401. type: number;
  402. count?: number;
  403. semantic?: string;
  404. node?: string;
  405. value?: number | boolean | string | Array<any>;
  406. source?: string;
  407. babylonValue?: any;
  408. }
  409. interface IGLTFTechniqueCommonProfile {
  410. lightingModel: string;
  411. texcoordBindings: Object;
  412. parameters?: Array<any>;
  413. }
  414. interface IGLTFTechniqueStatesFunctions {
  415. blendColor?: number[];
  416. blendEquationSeparate?: number[];
  417. blendFuncSeparate?: number[];
  418. colorMask: boolean[];
  419. cullFace: number[];
  420. }
  421. interface IGLTFTechniqueStates {
  422. enable: number[];
  423. functions: IGLTFTechniqueStatesFunctions;
  424. }
  425. interface IGLTFTechnique extends IGLTFChildRootProperty {
  426. parameters: {
  427. [key: string]: IGLTFTechniqueParameter;
  428. };
  429. program: string;
  430. attributes: {
  431. [key: string]: string;
  432. };
  433. uniforms: {
  434. [key: string]: string;
  435. };
  436. states: IGLTFTechniqueStates;
  437. }
  438. interface IGLTFMaterial extends IGLTFChildRootProperty {
  439. technique?: string;
  440. values: string[];
  441. }
  442. interface IGLTFMeshPrimitive extends IGLTFProperty {
  443. attributes: {
  444. [key: string]: string;
  445. };
  446. indices: string;
  447. material: string;
  448. mode?: number;
  449. }
  450. interface IGLTFMesh extends IGLTFChildRootProperty {
  451. primitives: IGLTFMeshPrimitive[];
  452. }
  453. interface IGLTFImage extends IGLTFChildRootProperty {
  454. uri: string;
  455. }
  456. interface IGLTFSampler extends IGLTFChildRootProperty {
  457. magFilter?: number;
  458. minFilter?: number;
  459. wrapS?: number;
  460. wrapT?: number;
  461. }
  462. interface IGLTFTexture extends IGLTFChildRootProperty {
  463. sampler: string;
  464. source: string;
  465. format?: ETextureFormat;
  466. internalFormat?: ETextureFormat;
  467. target?: number;
  468. type?: number;
  469. babylonTexture?: Texture;
  470. }
  471. interface IGLTFAmbienLight {
  472. color?: number[];
  473. }
  474. interface IGLTFDirectionalLight {
  475. color?: number[];
  476. }
  477. interface IGLTFPointLight {
  478. color?: number[];
  479. constantAttenuation?: number;
  480. linearAttenuation?: number;
  481. quadraticAttenuation?: number;
  482. }
  483. interface IGLTFSpotLight {
  484. color?: number[];
  485. constantAttenuation?: number;
  486. fallOfAngle?: number;
  487. fallOffExponent?: number;
  488. linearAttenuation?: number;
  489. quadraticAttenuation?: number;
  490. }
  491. interface IGLTFLight extends IGLTFChildRootProperty {
  492. type: string;
  493. }
  494. interface IGLTFCameraOrthographic {
  495. xmag: number;
  496. ymag: number;
  497. zfar: number;
  498. znear: number;
  499. }
  500. interface IGLTFCameraPerspective {
  501. aspectRatio: number;
  502. yfov: number;
  503. zfar: number;
  504. znear: number;
  505. }
  506. interface IGLTFCamera extends IGLTFChildRootProperty {
  507. type: string;
  508. }
  509. interface IGLTFAnimationChannelTarget {
  510. id: string;
  511. path: string;
  512. }
  513. interface IGLTFAnimationChannel {
  514. sampler: string;
  515. target: IGLTFAnimationChannelTarget;
  516. }
  517. interface IGLTFAnimationSampler {
  518. input: string;
  519. output: string;
  520. interpolation?: string;
  521. }
  522. interface IGLTFAnimation extends IGLTFChildRootProperty {
  523. channels?: IGLTFAnimationChannel[];
  524. parameters?: {
  525. [key: string]: string;
  526. };
  527. samplers?: {
  528. [key: string]: IGLTFAnimationSampler;
  529. };
  530. }
  531. interface IGLTFNodeInstanceSkin {
  532. skeletons: string[];
  533. skin: string;
  534. meshes: string[];
  535. }
  536. interface IGLTFSkins extends IGLTFChildRootProperty {
  537. bindShapeMatrix: number[];
  538. inverseBindMatrices: string;
  539. jointNames: string[];
  540. babylonSkeleton?: Skeleton;
  541. }
  542. interface IGLTFNode extends IGLTFChildRootProperty {
  543. camera?: string;
  544. children: string[];
  545. skin?: string;
  546. jointName?: string;
  547. light?: string;
  548. matrix: number[];
  549. mesh?: string;
  550. meshes?: string[];
  551. rotation?: number[];
  552. scale?: number[];
  553. translation?: number[];
  554. babylonNode?: Node;
  555. }
  556. interface IGLTFScene extends IGLTFChildRootProperty {
  557. nodes: string[];
  558. }
  559. /**
  560. * Runtime
  561. */
  562. interface IGLTFRuntime {
  563. extensions: {
  564. [key: string]: any;
  565. };
  566. accessors: {
  567. [key: string]: IGLTFAccessor;
  568. };
  569. buffers: {
  570. [key: string]: IGLTFBuffer;
  571. };
  572. bufferViews: {
  573. [key: string]: IGLTFBufferView;
  574. };
  575. meshes: {
  576. [key: string]: IGLTFMesh;
  577. };
  578. lights: {
  579. [key: string]: IGLTFLight;
  580. };
  581. cameras: {
  582. [key: string]: IGLTFCamera;
  583. };
  584. nodes: {
  585. [key: string]: IGLTFNode;
  586. };
  587. images: {
  588. [key: string]: IGLTFImage;
  589. };
  590. textures: {
  591. [key: string]: IGLTFTexture;
  592. };
  593. shaders: {
  594. [key: string]: IGLTFShader;
  595. };
  596. programs: {
  597. [key: string]: IGLTFProgram;
  598. };
  599. samplers: {
  600. [key: string]: IGLTFSampler;
  601. };
  602. techniques: {
  603. [key: string]: IGLTFTechnique;
  604. };
  605. materials: {
  606. [key: string]: IGLTFMaterial;
  607. };
  608. animations: {
  609. [key: string]: IGLTFAnimation;
  610. };
  611. skins: {
  612. [key: string]: IGLTFSkins;
  613. };
  614. currentScene?: Object;
  615. scenes: {
  616. [key: string]: IGLTFScene;
  617. };
  618. extensionsUsed: string[];
  619. extensionsRequired?: string[];
  620. buffersCount: number;
  621. shaderscount: number;
  622. scene: Scene;
  623. rootUrl: string;
  624. loadedBufferCount: number;
  625. loadedBufferViews: {
  626. [name: string]: ArrayBufferView;
  627. };
  628. loadedShaderCount: number;
  629. importOnlyMeshes: boolean;
  630. importMeshesNames?: string[];
  631. dummyNodes: Node[];
  632. }
  633. /**
  634. * Bones
  635. */
  636. interface INodeToRoot {
  637. bone: Bone;
  638. node: IGLTFNode;
  639. id: string;
  640. }
  641. interface IJointNode {
  642. node: IGLTFNode;
  643. id: string;
  644. }
  645. }
  646. declare module BABYLON.GLTF1 {
  647. /**
  648. * Implementation of the base glTF spec
  649. */
  650. class GLTFLoaderBase {
  651. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  652. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  653. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  654. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  655. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  656. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  657. }
  658. /**
  659. * glTF V1 Loader
  660. */
  661. class GLTFLoader implements IGLTFLoader {
  662. static Extensions: {
  663. [name: string]: GLTFLoaderExtension;
  664. };
  665. static RegisterExtension(extension: GLTFLoaderExtension): void;
  666. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  667. animationStartMode: GLTFLoaderAnimationStartMode;
  668. compileMaterials: boolean;
  669. useClipPlane: boolean;
  670. compileShadowGenerators: boolean;
  671. onDisposeObservable: Observable<IGLTFLoader>;
  672. onMeshLoadedObservable: Observable<AbstractMesh>;
  673. onTextureLoadedObservable: Observable<BaseTexture>;
  674. onMaterialLoadedObservable: Observable<Material>;
  675. onAnimationGroupLoadedObservable: Observable<AnimationGroup>;
  676. onCompleteObservable: Observable<IGLTFLoader>;
  677. onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  678. state: Nullable<GLTFLoaderState>;
  679. dispose(): void;
  680. private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress?, onError?);
  681. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  682. meshes: AbstractMesh[];
  683. particleSystems: ParticleSystem[];
  684. skeletons: Skeleton[];
  685. }>;
  686. private _loadAsync(scene, data, rootUrl, onSuccess, onProgress?, onError?);
  687. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  688. private _loadShadersAsync(gltfRuntime, onload);
  689. private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
  690. private _createNodes(gltfRuntime);
  691. }
  692. }
  693. declare module BABYLON.GLTF1 {
  694. /**
  695. * Utils functions for GLTF
  696. */
  697. class GLTFUtils {
  698. /**
  699. * Sets the given "parameter" matrix
  700. * @param scene: the {BABYLON.Scene} object
  701. * @param source: the source node where to pick the matrix
  702. * @param parameter: the GLTF technique parameter
  703. * @param uniformName: the name of the shader's uniform
  704. * @param shaderMaterial: the shader material
  705. */
  706. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  707. /**
  708. * Sets the given "parameter" matrix
  709. * @param shaderMaterial: the shader material
  710. * @param uniform: the name of the shader's uniform
  711. * @param value: the value of the uniform
  712. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  713. */
  714. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  715. /**
  716. * Returns the wrap mode of the texture
  717. * @param mode: the mode value
  718. */
  719. static GetWrapMode(mode: number): number;
  720. /**
  721. * Returns the byte stride giving an accessor
  722. * @param accessor: the GLTF accessor objet
  723. */
  724. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  725. /**
  726. * Returns the texture filter mode giving a mode value
  727. * @param mode: the filter mode value
  728. */
  729. static GetTextureFilterMode(mode: number): ETextureFilterType;
  730. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  731. /**
  732. * Returns a buffer from its accessor
  733. * @param gltfRuntime: the GLTF runtime
  734. * @param accessor: the GLTF accessor
  735. */
  736. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  737. /**
  738. * Decodes a buffer view into a string
  739. * @param view: the buffer view
  740. */
  741. static DecodeBufferToText(view: ArrayBufferView): string;
  742. /**
  743. * Returns the default material of gltf. Related to
  744. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  745. * @param scene: the Babylon.js scene
  746. */
  747. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  748. private static _DefaultMaterial;
  749. }
  750. }
  751. declare module BABYLON.GLTF1 {
  752. abstract class GLTFLoaderExtension {
  753. private _name;
  754. constructor(name: string);
  755. readonly name: string;
  756. /**
  757. * Defines an override for loading the runtime
  758. * Return true to stop further extensions from loading the runtime
  759. */
  760. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  761. /**
  762. * Defines an onverride for creating gltf runtime
  763. * Return true to stop further extensions from creating the runtime
  764. */
  765. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  766. /**
  767. * Defines an override for loading buffers
  768. * Return true to stop further extensions from loading this buffer
  769. */
  770. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  771. /**
  772. * Defines an override for loading texture buffers
  773. * Return true to stop further extensions from loading this texture data
  774. */
  775. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  776. /**
  777. * Defines an override for creating textures
  778. * Return true to stop further extensions from loading this texture
  779. */
  780. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  781. /**
  782. * Defines an override for loading shader strings
  783. * Return true to stop further extensions from loading this shader data
  784. */
  785. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  786. /**
  787. * Defines an override for loading materials
  788. * Return true to stop further extensions from loading this material
  789. */
  790. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  791. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  792. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  793. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  794. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  795. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  796. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  797. private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  798. private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  799. private static ApplyExtensions(func, defaultFunc);
  800. }
  801. }
  802. declare module BABYLON.GLTF1 {
  803. class GLTFBinaryExtension extends GLTFLoaderExtension {
  804. private _bin;
  805. constructor();
  806. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  807. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  808. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  809. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  810. }
  811. }
  812. declare module BABYLON.GLTF1 {
  813. class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  814. constructor();
  815. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  816. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  817. private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
  818. }
  819. }
  820. declare module BABYLON.GLTF2 {
  821. interface TypedArray extends ArrayBufferView {
  822. [index: number]: number;
  823. }
  824. interface IArrayItem {
  825. _index: number;
  826. }
  827. class ArrayItem {
  828. static Assign(values?: IArrayItem[]): void;
  829. }
  830. }
  831. declare module BABYLON.GLTF2 {
  832. interface ILoaderAccessor extends IAccessor, IArrayItem {
  833. _data?: Promise<TypedArray>;
  834. }
  835. interface ILoaderAnimationChannel extends IAnimationChannel, IArrayItem {
  836. }
  837. interface ILoaderAnimationSamplerData {
  838. input: Float32Array;
  839. interpolation: AnimationSamplerInterpolation;
  840. output: Float32Array;
  841. }
  842. interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem {
  843. _data: Promise<ILoaderAnimationSamplerData>;
  844. }
  845. interface ILoaderAnimation extends IAnimation, IArrayItem {
  846. channels: ILoaderAnimationChannel[];
  847. samplers: ILoaderAnimationSampler[];
  848. _babylonAnimationGroup?: AnimationGroup;
  849. }
  850. interface ILoaderBuffer extends IBuffer, IArrayItem {
  851. _data?: Promise<ArrayBufferView>;
  852. }
  853. interface ILoaderBufferView extends IBufferView, IArrayItem {
  854. _data?: Promise<ArrayBufferView>;
  855. }
  856. interface ILoaderCamera extends ICamera, IArrayItem {
  857. }
  858. interface ILoaderImage extends IImage, IArrayItem {
  859. _objectURL?: Promise<string>;
  860. }
  861. interface ILoaderMaterial extends IMaterial, IArrayItem {
  862. _babylonData?: {
  863. [drawMode: number]: {
  864. material: Material;
  865. meshes: AbstractMesh[];
  866. loaded: Promise<void>;
  867. };
  868. };
  869. }
  870. interface ILoaderMesh extends IMesh, IArrayItem {
  871. primitives: ILoaderMeshPrimitive[];
  872. }
  873. interface ILoaderMeshPrimitive extends IMeshPrimitive, IArrayItem {
  874. }
  875. interface ILoaderNode extends INode, IArrayItem {
  876. _parent: ILoaderNode;
  877. _babylonMesh?: Mesh;
  878. _primitiveBabylonMeshes?: Mesh[];
  879. _babylonAnimationTargets?: Node[];
  880. _numMorphTargets?: number;
  881. }
  882. interface ILoaderSamplerData {
  883. noMipMaps: boolean;
  884. samplingMode: number;
  885. wrapU: number;
  886. wrapV: number;
  887. }
  888. interface ILoaderSampler extends ISampler, IArrayItem {
  889. _data?: ILoaderSamplerData;
  890. }
  891. interface ILoaderScene extends IScene, IArrayItem {
  892. }
  893. interface ILoaderSkin extends ISkin, IArrayItem {
  894. _babylonSkeleton?: Skeleton;
  895. _loaded?: Promise<void>;
  896. }
  897. interface ILoaderTexture extends ITexture, IArrayItem {
  898. }
  899. interface ILoaderGLTF extends IGLTF {
  900. accessors?: ILoaderAccessor[];
  901. animations?: ILoaderAnimation[];
  902. buffers?: ILoaderBuffer[];
  903. bufferViews?: ILoaderBufferView[];
  904. cameras?: ILoaderCamera[];
  905. images?: ILoaderImage[];
  906. materials?: ILoaderMaterial[];
  907. meshes?: ILoaderMesh[];
  908. nodes?: ILoaderNode[];
  909. samplers?: ILoaderSampler[];
  910. scenes?: ILoaderScene[];
  911. skins?: ILoaderSkin[];
  912. textures?: ILoaderTexture[];
  913. }
  914. }
  915. declare module BABYLON.GLTF2 {
  916. interface MaterialConstructor<T extends Material> {
  917. readonly prototype: T;
  918. new (name: string, scene: Scene): T;
  919. }
  920. class GLTFLoader implements IGLTFLoader {
  921. _gltf: ILoaderGLTF;
  922. _babylonScene: Scene;
  923. _completePromises: Promise<void>[];
  924. private _disposed;
  925. private _state;
  926. private _extensions;
  927. private _rootUrl;
  928. private _rootBabylonMesh;
  929. private _defaultSampler;
  930. private _defaultBabylonMaterials;
  931. private _progressCallback?;
  932. private _requests;
  933. private static _Names;
  934. private static _Factories;
  935. static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
  936. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  937. animationStartMode: GLTFLoaderAnimationStartMode;
  938. compileMaterials: boolean;
  939. useClipPlane: boolean;
  940. compileShadowGenerators: boolean;
  941. readonly onDisposeObservable: Observable<IGLTFLoader>;
  942. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  943. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  944. readonly onMaterialLoadedObservable: Observable<Material>;
  945. readonly onAnimationGroupLoadedObservable: Observable<AnimationGroup>;
  946. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  947. readonly onCompleteObservable: Observable<IGLTFLoader>;
  948. readonly state: Nullable<GLTFLoaderState>;
  949. dispose(): void;
  950. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  951. meshes: AbstractMesh[];
  952. particleSystems: ParticleSystem[];
  953. skeletons: Skeleton[];
  954. }>;
  955. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  956. private _loadAsync(nodes, scene, data, rootUrl, onProgress?);
  957. private _loadExtensions();
  958. private _loadData(data);
  959. private _setupData();
  960. private _checkExtensions();
  961. private _createRootNode();
  962. private _loadNodesAsync(nodes);
  963. _loadSceneAsync(context: string, scene: ILoaderScene): Promise<void>;
  964. private _forEachPrimitive(node, callback);
  965. private _getMeshes();
  966. private _getSkeletons();
  967. private _startAnimations();
  968. _loadNodeAsync(context: string, node: ILoaderNode): Promise<void>;
  969. private _loadMeshAsync(context, node, mesh, babylonMesh);
  970. private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
  971. private _loadVertexDataAsync(context, primitive, babylonMesh);
  972. private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
  973. private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonVertexData);
  974. private _loadMorphTargetVertexDataAsync(context, babylonVertexData, attributes, babylonMorphTarget);
  975. private static _ConvertToFloat32Array(context, accessor, data);
  976. private static _ConvertVec3ToVec4(context, data);
  977. private static _LoadTransform(node, babylonNode);
  978. private _loadSkinAsync(context, node, mesh, skin);
  979. private _loadSkinInverseBindMatricesDataAsync(context, skin);
  980. private _createBone(node, skin, parent, localMatrix, baseMatrix, index);
  981. private _loadBones(context, skin, inverseBindMatricesData);
  982. private _loadBone(node, skin, inverseBindMatricesData, babylonBones);
  983. private _getNodeMatrix(node);
  984. private _loadAnimationsAsync();
  985. private _loadAnimationAsync(context, animation);
  986. private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
  987. private _loadAnimationSamplerAsync(context, sampler);
  988. private _loadBufferAsync(context, buffer);
  989. _loadBufferViewAsync(context: string, bufferView: ILoaderBufferView): Promise<ArrayBufferView>;
  990. private _loadAccessorAsync(context, accessor);
  991. private _buildArrayBuffer<T>(typedArray, data, byteOffset, count, numComponents, byteStride?);
  992. private _getDefaultMaterial(drawMode);
  993. private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
  994. _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Promise<void>;
  995. _createMaterial<T extends Material>(type: MaterialConstructor<T>, name: string, drawMode: number): T;
  996. _loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: PBRMaterial): Promise<void>;
  997. _loadMaterialAlphaProperties(context: string, material: ILoaderMaterial, babylonMaterial: PBRMaterial): void;
  998. _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Promise<void>;
  999. private _loadSampler(context, sampler);
  1000. private _loadImageAsync(context, image);
  1001. _loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  1002. private _onProgress();
  1003. static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1004. private static _GetTextureWrapMode(context, mode);
  1005. private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
  1006. private static _GetNumComponents(context, type);
  1007. private static _ValidateUri(uri);
  1008. private static _GetDrawMode(context, mode);
  1009. private _compileMaterialsAsync();
  1010. private _compileShadowGeneratorsAsync();
  1011. private _clear();
  1012. _applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>;
  1013. }
  1014. }
  1015. declare module BABYLON.GLTF2 {
  1016. abstract class GLTFLoaderExtension implements IGLTFLoaderExtension, IDisposable {
  1017. enabled: boolean;
  1018. readonly abstract name: string;
  1019. protected _loader: GLTFLoader;
  1020. constructor(loader: GLTFLoader);
  1021. dispose(): void;
  1022. /** Override this method to modify the default behavior for loading scenes. */
  1023. protected _loadSceneAsync(context: string, node: ILoaderScene): Nullable<Promise<void>>;
  1024. /** Override this method to modify the default behavior for loading nodes. */
  1025. protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>;
  1026. /** Override this method to modify the default behavior for loading mesh primitive vertex data. */
  1027. protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>;
  1028. /** Override this method to modify the default behavior for loading materials. */
  1029. protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  1030. /** Override this method to modify the default behavior for loading uris. */
  1031. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1032. /** Helper method called by a loader extension to load an glTF extension. */
  1033. protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (context: string, extension: TProperty) => Promise<TResult>): Nullable<Promise<TResult>>;
  1034. /** Helper method called by the loader to allow extensions to override loading scenes. */
  1035. static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  1036. /** Helper method called by the loader to allow extensions to override loading nodes. */
  1037. static _LoadNodeAsync(loader: GLTFLoader, context: string, node: ILoaderNode): Nullable<Promise<void>>;
  1038. /** Helper method called by the loader to allow extensions to override loading mesh primitive vertex data. */
  1039. static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>;
  1040. /** Helper method called by the loader to allow extensions to override loading materials. */
  1041. static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  1042. /** Helper method called by the loader to allow extensions to override loading uris. */
  1043. static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1044. }
  1045. }
  1046. declare module BABYLON.GLTF2.Extensions {
  1047. class MSFT_lod extends GLTFLoaderExtension {
  1048. readonly name: string;
  1049. /**
  1050. * Maximum number of LODs to load, starting from the lowest LOD.
  1051. */
  1052. maxLODsToLoad: number;
  1053. private _loadingNodeLOD;
  1054. private _loadNodeSignals;
  1055. private _loadingMaterialLOD;
  1056. private _loadMaterialSignals;
  1057. protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>;
  1058. protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  1059. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1060. /**
  1061. * Gets an array of LOD properties from lowest to highest.
  1062. */
  1063. private _getLODs<T>(context, property, array, ids);
  1064. }
  1065. }
  1066. declare module BABYLON.GLTF2.Extensions {
  1067. class KHR_draco_mesh_compression extends GLTFLoaderExtension {
  1068. readonly name: string;
  1069. private _dracoCompression;
  1070. constructor(loader: GLTFLoader);
  1071. dispose(): void;
  1072. protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>;
  1073. }
  1074. }
  1075. declare module BABYLON.GLTF2.Extensions {
  1076. class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
  1077. readonly name: string;
  1078. protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  1079. private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
  1080. }
  1081. }
  1082. declare module BABYLON.GLTF2.Extensions {
  1083. class KHR_lights extends GLTFLoaderExtension {
  1084. readonly name: string;
  1085. protected _loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  1086. protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>;
  1087. private readonly _lights;
  1088. }
  1089. }