babylonjs.loaders.module.d.ts 45 KB

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