cubes = {
const n_split = 16;
const boxRate = density;
const boxSize = boxRate * (1 / n_split);
const meshes = [];
const color = colorFunctions[selected];
for (let i = 0; i < n_split; i++) {
for (let j = 0; j < n_split; j++) {
for (let k = 0; k < n_split; k++) {
const r = Math.round(255 * i / n_split);
const g = Math.round(255 * j / n_split);
const b = Math.round(255 * k / n_split);
const geometry = new THREE.BoxGeometry(boxSize, boxSize, boxSize);
const material = new THREE.MeshBasicMaterial({color: color(r, g, b)});
const cube = new THREE.Mesh(geometry, material);
cube.position.set(
(i / n_split),
(j / n_split),
(k / n_split)
);
meshes.push(cube);
}
}
}
return meshes;
}