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 thebarrel.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 returningundefined
. I add aconsole.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?