babylon.objFileLoader.d.ts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. declare module BABYLON {
  2. /**
  3. * Class reading and parsing the MTL file bundled with the obj file.
  4. */
  5. class MTLFileLoader {
  6. materials: BABYLON.StandardMaterial[];
  7. /**
  8. * This function will read the mtl file and create each material described inside
  9. * This function could be improve by adding :
  10. * -some component missing (Ni, Tf...)
  11. * -including the specific options available
  12. *
  13. * @param scene
  14. * @param data
  15. * @param rootUrl
  16. */
  17. parseMTL(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string): void;
  18. /**
  19. * Gets the texture for the material.
  20. *
  21. * If the material is imported from input file,
  22. * We sanitize the url to ensure it takes the textre from aside the material.
  23. *
  24. * @param rootUrl The root url to load from
  25. * @param value The value stored in the mtl
  26. * @return The Texture
  27. */
  28. private static _getTexture(rootUrl, value, scene);
  29. }
  30. class OBJFileLoader implements ISceneLoaderPluginAsync {
  31. static OPTIMIZE_WITH_UV: boolean;
  32. static INVERT_Y: boolean;
  33. name: string;
  34. extensions: string;
  35. obj: RegExp;
  36. group: RegExp;
  37. mtllib: RegExp;
  38. usemtl: RegExp;
  39. smooth: RegExp;
  40. vertexPattern: RegExp;
  41. normalPattern: RegExp;
  42. uvPattern: RegExp;
  43. facePattern1: RegExp;
  44. facePattern2: RegExp;
  45. facePattern3: RegExp;
  46. facePattern4: RegExp;
  47. /**
  48. * Calls synchronously the MTL file attached to this obj.
  49. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  50. * Without this function materials are not displayed in the first frame (but displayed after).
  51. * In consequence it is impossible to get material information in your HTML file
  52. *
  53. * @param url The URL of the MTL file
  54. * @param rootUrl
  55. * @param onSuccess Callback function to be called when the MTL file is loaded
  56. * @private
  57. */
  58. private _loadMTL(url, rootUrl, onSuccess);
  59. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60. meshes: AbstractMesh[];
  61. particleSystems: ParticleSystem[];
  62. skeletons: Skeleton[];
  63. animationGroups: AnimationGroup[];
  64. }>;
  65. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  67. /**
  68. * Read the OBJ file and create an Array of meshes.
  69. * Each mesh contains all information given by the OBJ and the MTL file.
  70. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  71. *
  72. * @param meshesNames
  73. * @param scene BABYLON.Scene The scene where are displayed the data
  74. * @param data String The content of the obj file
  75. * @param rootUrl String The path to the folder
  76. * @returns Array<AbstractMesh>
  77. * @private
  78. */
  79. private _parseSolid(meshesNames, scene, data, rootUrl);
  80. }
  81. }