babylonjs.loaders.module.d.ts 45 KB

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