babylonjs.loaders.d.ts 45 KB

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