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. WorkerScript for heavy canvas3d application

WorkerScript for heavy canvas3d application

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
canvas3dworkerscriptqtquickqmljavascript
1 Posts 1 Posters 878 Views 1 Watching
  • 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.
  • Wiech_RVW Offline
    Wiech_RVW Offline
    Wiech_RV
    wrote on last edited by
    #1

    I have a qt quick application (buttons etc.) for user control and a canvas3d animation in the middle of the screen. However loading the javascript files with JSON.loader for the cad model takes a lot of time and my application freezes for some time. I was trying to run extra thread for the animation with WorkerScript in QML.

    The problem is that i cannot give the canvas3d object (QObject) ot the workerscript. Any idea how to solve that problem?

    Canvas3D  {
    id: canvas3d
    anchors.fill: parent
    anchors.verticalCenter: parent.verticalCenter
    anchors.horizontalCenter: parent.horizontalCenter
    focus: true
    
    WorkerScript {
        id: myWorker
        source: 'workerscript.js'
        onMessage: console.log(message.reply)
    }
    onInitializeGL: {
        //GLCode.init(canvas3d)
        myWorker.sendMessage(canvas3d)
    }
    WorkerScript.onMessage = function(message)
    {  
    initScene();
    initCamera(message.canvas)
    initMeshObjects();
    initRenderer(message.canvas);
    WorkerScript.sendMessage({'reply': 'WorkerScript done!'});
     }
    
    function initMeshObjects() {
        // ![1]
        var loader1 = new THREE.JSONLoader();
    
        loader1.load('/rightBack/chrome11.js', function(geometry, materials) {
        var material = new THREE.MeshBasicMaterial({color: 0xCBDAD5,
                                                       ambient: 0x00000000,
                                                       shading: THREE.SmoothShading});
        chrome11 = new THREE.Mesh(geometry, material);
        scene.add(chrome11);
    });
    }
    
    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