Using three.js in my Qt QML Program



  • Hi, I'd like to use three.js in my program to render .obj files. I've looked online at https://github.com/tronlec/three.js which describes a simple example that I can run on my own. I changed the program to have the following code for rendering an .obj file:

    var manager = new THREE.LoadingManager();
    loader = new THREE.OBJLoader(manager);
    loader.load('C:/Users/dillydill123/Documents/Qt/exampleProj/object.obj', function (object) {
    
        object.traverse(function (child) {
            if (child instanceof THREE.Mesh) {
                child.material.side = THREE.Material.DoubleSide;
            }
        });
    
        scene.add(object);
    });
    

    Unfortunately, when I run this code, I get type errors, saying that OBJLoader is not a type. It looks like the three.js library from https://github.com/tronlec/three.js/blob/master/build/three.js does not include OBJLoader. I've tried appending the source code of OBJLoader from https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader.js to the end of my three.js file in my QRC, but I get other type errors for FIleLoader. When I attempt to append that to three.js, I get other type errors.

    I also want to be able to use other extensions/modules from three.js, namely TrackBallControls. Unfortunately, I get other type errors when trying to append this to the end of my three.js.

    My questions are the following: How do I render a .obj file in Qt QML using three.js? And how can I easily add modules and extensions to three.js?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.