我正在使用three.js 来制作动画。我想动态更新立方体网格的材质。这是示例:
// create cube geometry
var material1 = [new THREE.MeshBasicMaterial({color:0xBEE2FF}),.....];
var geometry = new THREE.CubeGeometry(50, 50, 50,0,0,0,material1 );
var cube = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial());
// ...
var material2 = [new THREE.MeshBasicMaterial({color:0xFFFFFF}), ...];
cube.geometry.materials = material2;
如果我使用 CanvasRenderer,它可以工作。但是当我更改为 WebGL Renderer 时,它会抛出错误: Uncaught TypeError: Cannot read property 'map' of undefined
如何使用 WebGL 在运行时更新立方体的材质?