I'm a bit confused on how to make a voxel terrain with Arraymesh. How would I go about setting up the arrays? Currently I'm storing the voxels as a 1s and 0s in a 3dimensional list.

My code is below:

```
extends Spatial
var voxel = []
var verts = PoolVector3Array()
var normals = PoolVector3Array()
var indices = PoolIntArray()
func _ready():
#terrain generation code
var arr_mesh = ArrayMesh.new()
var mesh_arrays = []
mesh_arrays.resize(ArrayMesh.ARRAY_MAX)
for x in range(16):
for z in range(16):
for y in range(16):
if voxel[x][z][y]==1:
if x-1<0 || voxel[x-1][z][y]==0:
make_quad(Vector3(x,y,z), Vector3(x,y+1,z), Vector3(x,y+1,z+1), Vector3(x,y,z+1))
if x+1>15 || voxel[x+1][z][y]==0:
make_quad(Vector3(x+1,y,z+1), Vector3(x+1,y+1,z+1), Vector3(x+1,y+1,z), Vector3(x+1,y,z))
if y-1<0 || voxel[x][z][y-1]==0:
make_quad(Vector3(x+1,y,z), Vector3(x,y,z), Vector3(x,y,z+1), Vector3(x+1,y,z+1))
if y+1>15 || voxel[x][z][y+1]==0:
make_quad(Vector3(x+1,y+1,z+1), Vector3(x,y+1,z+1), Vector3(x,y+1,z), Vector3(x+1,y+1,z))
if z-1<0 || voxel[x][z-1][y]==0:
make_quad(Vector3(x+1,y,z), Vector3(x+1,y+1,z), Vector3(x,y+1,z), Vector3(x,y,z))
if z+1>15 || voxel[x][z+1][y]==0:
make_quad(Vector3(x,y,z+1), Vector3(x,y+1,z+1), Vector3(x+1,y+1,z+1), Vector3(x+1,y,z+1))
mesh_arrays[Mesh.ARRAY_VERTEX] = verts
mesh_arrays[Mesh.ARRAY_NORMAL] = normals
mesh_arrays[Mesh.ARRAY_INDEX] = indices
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, mesh_arrays)
get_node("MeshInstance").mesh = arr_mesh
func make_quad(a,b,c,d):
var length = len(verts)
indices.append_array([length, length+1, length+2, length, length+2, length+3])
verts.append_array([a,b,c,d])
normals.append_array([a.normalized(),b.normalized(),c.normalized(),d.normalized()])
```

This should generate a voxel world 16x16x16. The problem is that the terrain it generates is all white. How can I add textures to the terrain? I'm also not sure how I would go about changing the terrain? If I want to add a block would I have to go over the whole loop to calculate new arrays, but that would be to inefficient.