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

Corrupt GLB file crashes the app with an uncaught error #1701

Open
hamza-hajji opened this issue Oct 18, 2024 · 0 comments
Open

Corrupt GLB file crashes the app with an uncaught error #1701

hamza-hajji opened this issue Oct 18, 2024 · 0 comments

Comments

@hamza-hajji
Copy link
Contributor

Describe the bug

Loadig a corrupt GLB file (attached here) should be caught by the library user instead of crashing with a runtime error

c21.zip

To Reproduce
Steps to reproduce the behavior:

Try to load a corrupt GLB using GLTFLoaderPlugin, I modified glTF_Schependomlaan.html example with

//------------------------------------------------------------------------------------------------------------------
    // Import the modules we need for this example
    //------------------------------------------------------------------------------------------------------------------

    import {Viewer, GLTFLoaderPlugin} from "../../dist/xeokit-sdk.es.js";

    //------------------------------------------------------------------------------------------------------------------
    // Create a Viewer, arrange the camera
    //------------------------------------------------------------------------------------------------------------------

    const viewer = new Viewer({
        canvasId: "myCanvas",
        transparent: true
    });

    viewer.camera.eye = [-2.56, 8.38, 8.27];
    viewer.camera.look = [13.44, 3.31, -14.83];
    viewer.camera.up = [0.10, 0.98, -0.14];

    viewer.scene.selectedMaterial.fillAlpha = 0.1;

    //----------------------------------------------------------------------------------------------------------------------
    // Create a glTF loader plugin, load a glTF model, fit to view
    //----------------------------------------------------------------------------------------------------------------------

    const gltfLoader = new GLTFLoaderPlugin(viewer);

    const sceneModel = gltfLoader.load({
        id: "myModel",
        src: "../../assets/mymodel/c21.glb",
        edges: true
    });

    sceneModel.on("loaded", () => {
        viewer.cameraFlight.flyTo(sceneModel);
    });

    viewer.cameraControl.on("picked", function (e) {
        console.log(e.entity.id);
    })

An error is thrown

image

Expected behavior

I can catch the error either through try catch or using an event similar to "loaded"

model.on("loaded", () => {

});
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

1 participant