babylonjs.loaders.d.ts 45 KB

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