微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

dat.gui 无法删除菜单选项

如何解决dat.gui 无法删除菜单选项

我目前正在为国际象棋构建一个 3D 图形界面,我正在使用 dat.gui 来控制几个命令。一切正常,除非我想从 dat.gui 中删除一个控件并且它给出了一个我无法解决或修复的错误

dat.gui 实例是一个类的一部分,我们称之为“接口”,我在另一个对象中使用接口,然后我想从那里删除 dat.gui 的选项。

下面是我的代码的最小示例。

在 Interface.js 中:


 init(application) {
        super.init(application);
        this.gui = new dat.GUI();
        return true;
    }
 create(){ 
       this.cameras_controller = 
       this.appearance_folder.add(this.scene,'defaultCamera',this.scene.cameras_name).name('Cameras');
    }
 remove_camera(){
       this.gui.remove(this.cameras_controller);
    }

在另一个Class.js中:


    constructor(myinterface) {
        this.interface = myinterface; //here I get an instance of the class 'Interface' passed 
                                      //by reference
    }
    my_method(){
        this.interface.remove_camera();
    }

我得到的错误

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node

所以,在这一点上我已经尝试了各种各样的事情。最初我在“接口”类中没有方法,我直接调用“另一个类”,如 this.interface.gui.remove(this.interface.cameras_controller)。然后我尝试销毁整个 gui 并再次添加所有内容,但是,虽然它有效,但不是我想要的。

如果你成功了,感谢你抽出时间来帮助我:)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。