babylon.objFileLoader.d.ts 3.0 KB

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