babylonjs.loaders.module.d.ts 45 KB

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