babylon.objFileLoader.d.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. 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. facePattern5: RegExp;
  48. /**
  49. * Calls synchronously the MTL file attached to this obj.
  50. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  51. * Without this function materials are not displayed in the first frame (but displayed after).
  52. * In consequence it is impossible to get material information in your HTML file
  53. *
  54. * @param url The URL of the MTL file
  55. * @param rootUrl
  56. * @param onSuccess Callback function to be called when the MTL file is loaded
  57. * @private
  58. */
  59. private _loadMTL;
  60. /**
  61. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  62. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63. * @param scene the scene the meshes should be added to
  64. * @param data the glTF data to load
  65. * @param rootUrl root url to load from
  66. * @param onProgress event that fires when loading progress has occured
  67. * @param fullName Defines the FQDN of the file to load
  68. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69. */
  70. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  71. meshes: AbstractMesh[];
  72. particleSystems: IParticleSystem[];
  73. skeletons: Skeleton[];
  74. animationGroups: AnimationGroup[];
  75. }>;
  76. /**
  77. * Imports all objects from the loaded glTF data and adds them to the scene
  78. * @param scene the scene the objects should be added to
  79. * @param data the glTF data to load
  80. * @param rootUrl root url to load from
  81. * @param onProgress event that fires when loading progress has occured
  82. * @param fullName Defines the FQDN of the file to load
  83. * @returns a promise which completes when objects have been loaded to the scene
  84. */
  85. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  86. /**
  87. * Load into an asset container.
  88. * @param scene The scene to load into
  89. * @param data The data to import
  90. * @param rootUrl The root url for scene and resources
  91. * @param onProgress The callback when the load progresses
  92. * @param fullName Defines the FQDN of the file to load
  93. * @returns The loaded asset container
  94. */
  95. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<AssetContainer>;
  96. /**
  97. * Read the OBJ file and create an Array of meshes.
  98. * Each mesh contains all information given by the OBJ and the MTL file.
  99. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  100. *
  101. * @param meshesNames
  102. * @param scene BABYLON.Scene The scene where are displayed the data
  103. * @param data String The content of the obj file
  104. * @param rootUrl String The path to the folder
  105. * @returns Array<AbstractMesh>
  106. * @private
  107. */
  108. private _parseSolid;
  109. }
  110. }