Important: Please read the Qt Code of Conduct -

How to I prepare models for Canvas3D view?

  • I am trying to learn how to display and interact with 3D models in qt. One way I am trying is using the Canvas3D. I opened the canvas3d/interaction example and tried replacing barrel.json file with my own file. I am using blender and the threejs plugin to generate the json file. Right now I am using the default blender monkey mesh and converting it to json. I have not changed the code for the sample app at all -- just replaced the barrel.json with my generated monkey mesh. Instead of an interactive 3D monkey head, I get the following error:

    QML debugging is enabled. Only use this in a safe environment.
    qrc:/interaction.js:298: TypeError: Cannot read property 'vertices' of undefined

    This error is happening because the call to parseJSON3DModel is failing and returning undefined. I add a console.log to the function below to verify that:

    function handleLoadedModel(jsonObj) {
        log("handleLoadedModel ENTER...")
        var modelData = parseJSON3DModel(jsonObj, "");
        console.log("model is " + modelData);
        log("    "+theModel.verticesVBO);
        gl.bindBuffer(gl.ARRAY_BUFFER, theModel.verticesVBO);
                      new Float32Array(modelData.vertices),

    So my question is: why is the call to parseJSON3DModel failing on 3D json models? I have tried this with a few different meshes now. How can I create a mesh or modify the Canvas3D code so that I can display 3D content?

  • Try to triangulate faces of your mesh (select your shape, switch to Edit Mode and press Ctrl+T ).

Log in to reply