I am attempting to construct a 3*3*3 matrix where each element will hold a cube. Currently, all the cubes are arranged in a 1D matrix called all_cube
. However, I need to organize them in a 3D matrix named cube[][][]
.
Below is the code for a more detailed explanation:
function createCubie()
{
all_cube=[];
for(var i= -1;i<=1;i++)
{
for(var j= -1;j<=1;j++)
{
for(var k= -1;k<=1;k++)
{
var cube = new THREE.Mesh( geometry, material );
cube.translateX(i*5.5);
cube.translateY(j*5.5);
cube.translateZ(k*5.5);
scene.add( cube );
all_cube.push(cube);
}
}
}
}