babylon.objFileLoader.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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;
  29. }
  30. class OBJFileLoader implements ISceneLoaderPluginAsync {
  31. static OPTIMIZE_WITH_UV: boolean;
  32. /**
  33. * Invert model on y-axis (does a model scaling inversion)
  34. */
  35. static INVERT_Y: boolean;
  36. /**
  37. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  38. */
  39. static IMPORT_VERTEX_COLORS: boolean;
  40. /**
  41. * Compute the normals for the model, even if normals are present in the file
  42. */
  43. static COMPUTE_NORMALS: boolean;
  44. name: string;
  45. extensions: string;
  46. obj: RegExp;
  47. group: RegExp;
  48. mtllib: RegExp;
  49. usemtl: RegExp;
  50. smooth: RegExp;
  51. vertexPattern: RegExp;
  52. normalPattern: RegExp;
  53. uvPattern: RegExp;
  54. facePattern1: RegExp;
  55. facePattern2: RegExp;
  56. facePattern3: RegExp;
  57. facePattern4: RegExp;
  58. facePattern5: RegExp;
  59. /**
  60. * Calls synchronously the MTL file attached to this obj.
  61. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  62. * Without this function materials are not displayed in the first frame (but displayed after).
  63. * In consequence it is impossible to get material information in your HTML file
  64. *
  65. * @param url The URL of the MTL file
  66. * @param rootUrl
  67. * @param onSuccess Callback function to be called when the MTL file is loaded
  68. * @private
  69. */
  70. private _loadMTL;
  71. /**
  72. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  73. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74. * @param scene the scene the meshes should be added to
  75. * @param data the OBJ data to load
  76. * @param rootUrl root url to load from
  77. * @param onProgress event that fires when loading progress has occured
  78. * @param fileName Defines the name of the file to load
  79. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80. */
  81. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82. meshes: AbstractMesh[];
  83. particleSystems: IParticleSystem[];
  84. skeletons: Skeleton[];
  85. animationGroups: AnimationGroup[];
  86. }>;
  87. /**
  88. * Imports all objects from the loaded OBJ data and adds them to the scene
  89. *
  90. * @param scene the scene the objects should be added to
  91. * @param data the OBJ data to load
  92. * @param rootUrl root url to load from
  93. * @param onProgress event that fires when loading progress has occured
  94. * @param fileName Defines the name of the file to load
  95. * @returns a promise which completes when objects have been loaded to the scene
  96. */
  97. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98. /**
  99. * Load into an asset container.
  100. * @param scene The scene to load into
  101. * @param data The data to import
  102. * @param rootUrl The root url for scene and resources
  103. * @param onProgress The callback when the load progresses
  104. * @param fileName Defines the name of the file to load
  105. * @returns The loaded asset container
  106. */
  107. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108. /**
  109. * Read the OBJ file and create an Array of meshes.
  110. * Each mesh contains all information given by the OBJ and the MTL file.
  111. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  112. *
  113. * @param meshesNames
  114. * @param scene BABYLON.Scene The scene where are displayed the data
  115. * @param data String The content of the obj file
  116. * @param rootUrl String The path to the folder
  117. * @returns Array<AbstractMesh>
  118. * @private
  119. */
  120. private _parseSolid;
  121. }
  122. }