babylon.objFileLoader.d.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: Scene, data: string, 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 ISceneLoaderPlugin {
  31. static OPTIMIZE_WITH_UV: boolean;
  32. extensions: string;
  33. obj: RegExp;
  34. group: RegExp;
  35. mtllib: RegExp;
  36. usemtl: RegExp;
  37. smooth: RegExp;
  38. vertexPattern: RegExp;
  39. normalPattern: RegExp;
  40. uvPattern: RegExp;
  41. facePattern1: RegExp;
  42. facePattern2: RegExp;
  43. facePattern3: RegExp;
  44. facePattern4: RegExp;
  45. /**
  46. * Calls synchronously the MTL file attached to this obj.
  47. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  48. * Without this function materials are not displayed in the first frame (but displayed after).
  49. * In consequence it is impossible to get material information in your HTML file
  50. *
  51. * @param url The URL of the MTL file
  52. * @param rootUrl
  53. * @param onSuccess Callback function to be called when the MTL file is loaded
  54. * @private
  55. */
  56. private _loadMTL(url, rootUrl, onSuccess);
  57. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]): boolean;
  58. load(scene: Scene, data: string, rootUrl: string): boolean;
  59. /**
  60. * Read the OBJ file and create an Array of meshes.
  61. * Each mesh contains all information given by the OBJ and the MTL file.
  62. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  63. *
  64. * @param meshesNames
  65. * @param scene BABYLON.Scene The scene where are displayed the data
  66. * @param data String The content of the obj file
  67. * @param rootUrl String The path to the folder
  68. * @returns Array<AbstractMesh>
  69. * @private
  70. */
  71. private _parseSolid(meshesNames, scene, data, rootUrl);
  72. }
  73. }