babylonjs.loaders.module.d.ts 45 KB

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