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

前端 未结 2 1623
难免孤独
难免孤独 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: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);
    

提交回复
热议问题