babylon.objFileLoader.d.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 ISceneLoaderPlugin {
  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. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  60. load(scene: Scene, data: string, rootUrl: string): boolean;
  61. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  62. /**
  63. * Read the OBJ file and create an Array of meshes.
  64. * Each mesh contains all information given by the OBJ and the MTL file.
  65. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66. *
  67. * @param meshesNames
  68. * @param scene BABYLON.Scene The scene where are displayed the data
  69. * @param data String The content of the obj file
  70. * @param rootUrl String The path to the folder
  71. * @returns Array<AbstractMesh>
  72. * @private
  73. */
  74. private _parseSolid(meshesNames, scene, data, rootUrl);
  75. }
  76. }