问题描述
我目前正在为国际象棋构建一个 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 (将#修改为@)