Three.js & Dat.gui - TrackballControls renderer.domElement disables rotate and pan

前端 未结 2 1624
难免孤独
难免孤独 2021-01-20 20:07

I am trying to use dat.gui with a very simple three.js (r73) scene but am running into an issue with rotate and pan not working after adding \"renderer.domElement\" to the t

相关标签:
2条回答
  • 2021-01-20 20:17

    Make sure the renderer DOM element is added to the html before it is being used as a reference.

    document.body.appendChild(renderer.domElement);
    
    0 讨论(0)
  • 2021-01-20 20:38

    I debugged the issue with the help of this post: Three.js Restrict the mouse movement to Scene only.

    Apparently, if you append the renderer.domElement child after initializing the trackballControls, it doesn't know anything about the renderer.domElement object. This also does something strange to dat.gui as described previously.

    Basically, make sure this line:

    document.getElementById("WebGL-output").appendChild(renderer.domElement);
    

    appears before this line:

    var trackballControls = new THREE.TrackballControls(camera, renderer.domElement);
    
    0 讨论(0)
提交回复
热议问题