Issue while using dat.GUI in a three.js example

前端 未结 3 908
情话喂你
情话喂你 2021-01-02 05:56

I tried to use dat.GUI in the following three.js example.

I just did the following code changes to add a GUI to adjust mesh opacity.



        
3条回答
  •  庸人自扰
    2021-01-02 06:29

    Old subject but I just have a similar issue and previous solution wasn't ok for my case. To fix it I create a specific canvas for the dat.gui module:

    Html part:

    Css part:

    #my-gui-container{
        position: absolute; 
        top: 0; 
        right: 0;
        z-index: 100;
    }
    

    Js Part:

    this.gui = new dat.GUI({ autoPlace: false });
    
    var customContainer = document.getElementById('my-gui-container');
    customContainer.appendChild(this.gui.domElement);
    

    With this method the elements are isolate and I have no event conflict anymore.

    Edit: for more details you have all code here https://github.com/quentinchap/threeJs-morphing-test

提交回复
热议问题