【发布时间】:2020-01-18 03:05:42
【问题描述】:
我希望我的网格的纹理在点击功能时更新。
当您单击“UpdateMateria”功能时,我希望网格能够处理其当前纹理并添加一个新纹理。
动画循环
startAnimationLoop = () => {
const tableBoard = this.scene.getObjectByName('tableSurface');
tableBoard.material.map = this.updateMateria;
this.renderer.render(this.scene, this.camera);
this.requestID = window.requestAnimationFrame(this.startAnimationLoop);
};
Dat.Gui
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')
}
}
当我将函数直接放入“动画循环”时,这实际上会将纹理更新为所需的纹理,但当前版本给出了“TypeError:无法读取未定义的属性“处置””
【问题讨论】: