babylonjs.loaders.module.d.ts 44 KB

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