Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to I prepare models for Canvas3D view?
Forum Update on Monday, May 27th 2025

How to I prepare models for Canvas3D view?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3d canvasmeshjson
2 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ArasA Offline
    ArasA Offline
    Aras
    wrote on last edited by
    #1

    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:

    Desktop_Qt_5_7_0_GCC_64bit-Debug/interaction...
    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("*******************************************************************************************");
        log("handleLoadedModel ENTER...")
        var modelData = parseJSON3DModel(jsonObj, "");
    
        console.log("model is " + modelData);
    
        log("    "+theModel.verticesVBO);
        gl.bindBuffer(gl.ARRAY_BUFFER, theModel.verticesVBO);
        gl.bufferData(gl.ARRAY_BUFFER,
                      new Float32Array(modelData.vertices),
                      gl.STATIC_DRAW);
    

    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?

    1 Reply Last reply
    0
    • U Offline
      U Offline
      upenya
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved