MetalWorldTextureScan icon indicating copy to clipboard operation
MetalWorldTextureScan copied to clipboard

Exporting textured model as GLTF

Open michael-martinez opened this issue 3 years ago • 2 comments

As a first step I exported the model to OBJ (meshes only).

Please note that I had to perform the following changes:

  • store geometry as an attribute when previewing
  • add save button
  • assign a name to each material else there was a crash when exporting

I want to have a textured mesh in standard GLTF format. I can see two main options:

  1. Generate OBJ file along with MTL file and use some converter such as https://github.com/CesiumGS/obj2gltf or https://github.com/javagl/JglTF/tree/master/jgltf-obj
  2. When previewing, as we have one mesh node having N scan nodes as children with the texture information, we can maybe in some way export this scene kit node or the whole ARSCNView in apple format USDZ which can then be converted to GLTF.

Do you have any clue about the way I should process?

EDIT: Update: The second approach is the correct one, the following code allows to export the USDZ file with textured mesh:

let fileName = "Mesh"
let documentDirURL = try! FileManager.default.url(for: .documentDirectory,
    in: .userDomainMask,
    appropriateFor: nil,
    create: true)
let fileURL = documentDirURL.appendingPathComponent(fileName).appendingPathExtension("usdz")
self.arView.scene.write(to: fileURL, options: nil, delegate: nil, progressHandler: nil)

michael-martinez avatar Mar 29 '22 11:03 michael-martinez

Hi Michael,

Reality Converter is the best way I’ve found for getting models converted to USDZ. You can load a mesh in with several material slots and assign them separately.

You can import OBJ files with Reality Converter, and also FBX files if you install the correct extras Python components.

I’ve found models less than 50meg work really well. We want to keep models sizes lower so we can have more in the scene.

Have you had a go with the app yet? It would be good for you to try importing the files.

Regarding GLTF, I have no direct way of importing them, so that why I’m more OBJ/USDZ/DAE focused.

Talk soon cheers, Dan

On 30/03/2022, at 00:44, Michaël Martinez @.***> wrote:

 As a first step I exported the model to OBJ (meshes only).

Please note that I had to perform the following changes:

store geometry as an attribute when previewing add save button assign a name to each material else there was a crash when exporting I want to have a textured mesh in standard GLTF format. I can see two main options:

Generate OBJ file along with MTL file and use some converter such as https://github.com/CesiumGS/obj2gltf or https://github.com/javagl/JglTF/tree/master/jgltf-obj When previewing, as we have one mesh node having N scan nodes as children with the texture information, we can maybe in some way export this scene kit node or the whole ARSCNView in apple format USDZ which can then be converted to GLTF. Do you have any clue about the way I should process?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

danmonaghan avatar Mar 29 '22 15:03 danmonaghan

@michael-martinez glad you got it working. Yes, a function for saving a mesh is in there but no button currently hooked up. Feel free to make a pull request if you want. We could add a pop up sheet with a few different export formats.

beatTheSystem42 avatar Mar 29 '22 15:03 beatTheSystem42