babylonjs.loaders.d.ts 45 KB

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