kovacsv / assimpjs

The emscripten interface for the assimp library that allows you to import 40+ 3D file formats in the browser.
MIT License
111 stars 18 forks source link

ASSIMP in the browser with ASSIMPJS and three.js #8

Closed GitHubDragonFly closed 1 year ago

GitHubDragonFly commented 1 year ago

This is intended for those who would like to see ASSIMP(JS) working in the browser.

The ASSIMP Viewer, which is a part of my repository, is sort of a hybrid between ASSIMPJS and three.js and can show a multitude of different 3D models (see the description in the repository).

Probably the best choice for the models would be the test folder from the ASSIMP repository, either downloaded to the computer for a local access or used remotely for example with a URL like this: https://raw.githubusercontent.com/assimp/assimp/master/test/models/IQM/mrfixit.iqm.

If Viktor ever finds a time to update this repository then that my fix some issues that are present currently with a small number of 3D formats. Not all the models in the ASSIMP repository are perfect either and my viewer probably has bugs.

kovacsv commented 1 year ago

Nice project @GitHubDragonFly. I'll do the update soon.

kovacsv commented 1 year ago

I've done the update.

GitHubDragonFly commented 1 year ago

That's cool Viktor.

Even though I updated my viewer and made slight code changes, still there is no improvement that I can see. This is fine since the viewer still works the same and can be used as such.

GitHubDragonFly commented 1 year ago

Viktor, just checked your test.js file and it shows that following importers are disabled: IFC, IRR, IRRMESH, M3D, RAW, TER, X3D.

Is the wasm file size a real consideration and a reason for disabling these importers?

Would you ever be able to actually enable all the ASSIMP importers and provide a wasm file separately? I wouldn't mind including it as such in my repository alongside ASSIMPJS instead of relying on linking the viewer to npm.

GitHubDragonFly commented 1 year ago

Never mind about this since I just followed your instructions and built the wasm file myself.

kovacsv commented 1 year ago

Viktor, just checked your test.js file and it shows that following importers are disabled: IFC, IRR, IRRMESH, M3D, RAW, TER, X3D.

Is the wasm file size a real consideration and a reason for disabling these importers?

Would you ever be able to actually enable all the ASSIMP importers and provide a wasm file separately? I wouldn't mind including it as such in my repository alongside ASSIMPJS instead of relying on linking the viewer to npm.

It's either wasm file size (in case of IFC) or I was not able to make them work (unfortunately I don't remember what was the case for each). If they seem to work, and the wasm size didn't increase a lot we can include them in the "official" package.

GitHubDragonFly commented 1 year ago

Currently the wasm size that I have is 6.65MB with all importers/exporters enabled.

This also includes M3D support from the ASSIMP's CMakeLists file.

Another change that I made is in the code below (I am only using FBX for exporting):

static std::string GetFileNameFromFormat (const std::string& format)
{
    std::string fileName = "result";
    if (format == "assjson") {
        fileName += ".json";
    } else if (format == "assxml") {
        fileName += ".xml";
    } else if (format == "gltf" || format == "gltf2") {
        fileName += ".gltf";
    } else if (format == "glb" || format == "glb2") {
        fileName += ".glb";
    } else if (format == "opengex") {
        fileName += ".ogex";
    } else if (format == "collada") {
        fileName += ".dae";
    } else if (format == "step") {
        fileName += ".stp";
    } else if (format == "obj") {
        fileName += ".obj";
    } else if (format == "ply") {
        fileName += ".ply";
    } else if (format == "stl") {
        fileName += ".stl";
    } else if (format == "fbx") {
        fileName += ".fbx";
    } else if (format == "3ds") {
        fileName += ".3ds";
    } else if (format == "3mf") {
        fileName += ".3mf";
    } else if (format == "m3d") {
        fileName += ".m3d";
    } else if (format == "x3d") {
        fileName += ".x3d";
    } else if (format == "x") {
        fileName += ".x";
    }
    return fileName;
}

There seems to be a lot of stuff in the ASSIMP library that might still need to be fixed or improved.