Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用ThreeJS&Dat.Gui更新网格的纹理_Reactjs_Three.js_Dat.gui - Fatal编程技术网

Reactjs 使用ThreeJS&Dat.Gui更新网格的纹理

Reactjs 使用ThreeJS&Dat.Gui更新网格的纹理,reactjs,three.js,dat.gui,Reactjs,Three.js,Dat.gui,我想我的网格纹理更新时,点击功能 单击“UpdateMatria”函数时,我希望网格处理其当前纹理并添加新纹理 动画循环 Dat.Gui 当我将函数直接放入“动画循环”时,这实际上会将纹理更新为所需的纹理,但当前版本首先给出了“TypeError:无法读取未定义的属性“dispose”,您不能在updateMaterial中使用此引用,可能是updateMaterial???。考虑在这个函数的外部变量中引用这个引用,而不是使用这个变量。此外,如果只想更改纹理,则无需处理材质 userGUI =

我想我的网格纹理更新时,点击功能

单击“UpdateMatria”函数时,我希望网格处理其当前纹理并添加新纹理

动画循环

Dat.Gui


当我将函数直接放入“动画循环”时,这实际上会将纹理更新为所需的纹理,但当前版本首先给出了“TypeError:无法读取未定义的属性“dispose”

,您不能在updateMaterial中使用此引用,可能是updateMaterial???。考虑在这个函数的外部变量中引用这个引用,而不是使用这个变量。此外,如果只想更改纹理,则无需处理材质

userGUI = () => {

    const scope = this;

    const update = {
        updateMateria: function() {
            alert('Changing');
            // scope.material.dispose();
            scope.material.map = texture1();
        }
    }

    this.gui = new dat.GUI();
    const controls = function() {
    this.title = new controls();
    this.gui.add(update, 'updateMateria')

}
3.js R108

  userGUI = () => {

    const update = {
      updateMateria: function() {
        alert('Changing');
        this.material.dispose();
        this.material.map = texture1();
      }
    }

    this.gui = new dat.GUI();
    const controls = function() {
    this.title = new controls();
    this.gui.add(update, 'updateMateria')
  }
}
userGUI = () => {

    const scope = this;

    const update = {
        updateMateria: function() {
            alert('Changing');
            // scope.material.dispose();
            scope.material.map = texture1();
        }
    }

    this.gui = new dat.GUI();
    const controls = function() {
    this.title = new controls();
    this.gui.add(update, 'updateMateria')

}