babylonjs.loaders.d.ts 45 KB

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