I am using Babylon’s FilesInput for listening to an upload from the user. I have also implemented the import for an .obj file. So a user gives to babylon an .obj file with an .mtl file for the materials and .jpg for the texture. However let’s say that my user have multiple textures in multiple .jpg files. I noticed that babylon.js just applies the last one and don’t consider the others .jpg files. Is there a way to fix this? To clarify my question. With the structure:
Yes I just tried different configurations in the sandbox, by changing the last texture file applied(for example interchanging the name of textureFile2 and textureFile3) the result is completely different, so it means all the textureFiles are not applied. because in the other case, the result should be the same.
Note: I made a small edit to my post, it seems that it’s the last textureFile that is applied to the scene, not the first one.
Here below you can see in the first picture a screenshot of the sandbox with the original files structure. and in the second image it’s a screenshot of the sandbox with the same files but just I switched names between the textureFile1 and textureFile3 (in other terms the textureFile1 is the last textureFile read in the second image)
This photogrammetric model (“Reservoir_multi-texture”) was exported straight from Agisoft Metashape Pro. For testing purposes, here we deliberately asked the software to split the texture into multiple images during its building process since there are good chances that some of the models we’ll be confronted with in the future will have multiple textures mapped this way. While the 3D scans we produce on our side using Metashape are typically single-textured, some of the files obtained from outside sources (municipal/academic libraries, partners, or drone-mapping services) are sometimes prepared as multi-textured OBJs. We’re trying to minimize as much as possible the pre-processing needed before being up and running in Babylonjs (future users won’t always have the software skills or time to remap textures).
We already plan on using the 3DSMax and Blender exporters when possible for projects where other geometries are added over the scan meshes, they manage the textures wonderfully. But some of our projects were designed in Rhino3D and exporting from Rhino to 3DSMax can be tiresome so we’re looking into getting OBJs straight from there to Babylonjs. After modeling and exporting some quick test scenes, it seems Rhino behaves in the same way Metashape does (as well as some other photogrammetry softwares) with multi-material OBJs, leading Babylonjs to apply the last appended usemtl definition to all the geometries within the OBJ file.
Here are the test files exported from Rhino3D in case you want to fiddle around: