Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverting gltf2 files #2

Open
Abhiram3 opened this issue May 12, 2022 · 1 comment
Open

Coverting gltf2 files #2

Abhiram3 opened this issue May 12, 2022 · 1 comment

Comments

@Abhiram3
Copy link

Hi,
I am trying to convert a gltf2 file into glb2 by adding all the files to the filelist. But the resultant "glb" file still has uri's to texture files.

I used http://3dviewer.net/index.html to visualize the models.

GLTF2 view of model

gltf_view

converted the gltf2 file with the following code.
`assimpjs.then ((ajs) => {
let fileList = new ajs.FileList ();
fileList.AddFile (
'scene.gltf',
fs.readFileSync ("/home/3d-viewer/Microservice-Template/testFiles/breakfast_gltf/scene.gltf")
);

fileList.AddFile (
    'scene.bin',
    fs.readFileSync ("/home/3d-viewer/Microservice-Template/testFiles/breakfast_gltf/scene.bin")
);

fileList.AddFile (
    'lambert1_baseColor.png',
    fs.readFileSync ("/home/3d-viewer/Microservice-Template/testFiles/breakfast_gltf/textures/lambert1_baseColor.png")
);

fileList.AddFile (
    'lambert1_metallicRoughness.png',
    fs.readFileSync ("/home/3d-viewer/Microservice-Template/testFiles/breakfast_gltf/textures/lambert1_metallicRoughness.png")
);

fileList.AddFile (
    'lambert1_normal.png',
    fs.readFileSync ("/home/3d-viewer/Microservice-Template/testFiles/breakfast_gltf/textures/lambert1_normal.png")
);

// convert file list to assimp json
let result = ajs.ConvertFileList (fileList, 'glb2');

// check if the conversion succeeded
if (!result.IsSuccess () || result.FileCount () == 0) {
    const errorCode = result.GetErrorCode ()
    console.log("errorCode", errorCode)
    return
}

// get the result file, and convert to string
let resultFile = result.GetFile (0);
    fs.writeFile(`breakfastTestGltf.glb`, resultFile.GetContent(), (e) => {
        if (e) {
            const errorCode = result.GetErrorCode ()
            console.log("error", e, errorCode);
        } else {
            console.log("success");
        }
    })

});`

The generated glb file gave the following view. It missed the texture files. 3dViewer mentioned regarding the missing files and glb file still had some urls of texture files.

breakfast_gltf

Is this not the right way to do it?

@kovacsv
Copy link
Owner

kovacsv commented May 14, 2022

I think that's an error in assimp's glb exporter so you should probably report the issue there. Side note: https://3dviewer.net can export to glb, and probably it does a better job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants