Currently, I am utilizing three.js to create animations. My goal is to dynamically modify the material of a cube mesh. Below is an example:
// 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;
When using the CanvasRenderer, everything works as expected. However, upon switching to WebGL Renderer, an error is thrown: Uncaught TypeError: Cannot read property 'map' of undefined
Is there a way to update the material of a cube during runtime while using WebGL?