HSF / root_cern-To_gltf-Exporter

3 stars 6 forks source link

conversion stuck #13

Open davzuliani opened 3 months ago

davzuliani commented 3 months ago

Hi,

I'm trying to use this tool to get a working GLTF file to be used with Phoenix. I was trying to reproduce the LHCb.gltf following the procedure shown, but it seems the process get stuck when deduplicating materials.

sync function convert_geometry(obj3d, name, body) {
    body.innerHTML += "<h2>Exporting to GLTF</h2>"
    await forceDisplay()
    const exporter = new THREE.GLTFExporter;
    let gltf = await new Promise(resolve =>
        exporter.parse(obj3d, resolve, {'binary':false})
    )
    body.innerHTML += "<h2>Finish!</h2>"
    // json output
    body.innerHTML += "<h2>Deduplicating data in GLTF</h2>"    
    await forceDisplay()
    gltf = await deduplicate(gltf, body);
    const fileToSave = new Blob([JSON.stringify(gltf)], {
        type: 'application/json',
        name: name
    });
    saveAs(fileToSave, name);
}

Now, what should be the elapsed time for the whole procedure? Or is it really stuck?

Thank you for your help, Davide

davzuliani commented 3 months ago

just to add a detail

    // scan them, build table of correspondance
    var kept = []
    var links = {}
    var materials = gltf["materials"];
    body.innerHTML += "initial number of materials : " + materials.length + "</br>"

it doesn't print the "initial number of materials" statement, which makes me thing that it stucks before that

sponce commented 2 months ago

This is now understood and was due to changes both in GLTF (minor API change) and JSROOT (looks more like a bug in version 7.0). I've pushed fixes but for the ROOT part, it's only hardcoding version 7.6.1, which is the last one working. Starting with 7.0.0, it seems that materials are not converted anymore when calling build on the object acquired form JSROOT.require('geom'). To be further investigated