How to create a mesh that acts as a uniform cubicle 3D lattice?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By toblin

I’m trying to setup shaders for GPU acceleration on 3D data points. To do so, I need to create a mesh that has vertices uniformly spread out in a 3D cubicle lattice. I.e. for each x,y,z in say [-2, -1, 0, 1, 2], I need a mesh vertex at (x,y,z).

My best approach thus far is to use an ArrayMesh. But what would be the easiest/best way of doing so?

:bust_in_silhouette: Reply From: klaas

when you mean a cube with a certain subdivision.

MeshInstance → mesh: new CubeMesh → click the small image of the cube
edit Size and subdivides

No, that would only give me vertices that lie on the “shell” of the cube, right? I need every volumetric point in the “cube” to have a vertex as well. Hence if x,y,z are in the set {-1,0,1}, then I need a vertex for the interior point (0,0,0) as well, and not just the exterior points.

toblin | 2020-09-09 10:12

:bust_in_silhouette: Reply From: klaas

ah, i see you mean:

extends MeshInstance

export(bool) var update setget _update

func _update(value):
	if value:

func update():
	mesh =
	var st =
	for x in range(0,10):
		for y in range(0,10):
			for z in range(0,10):
	mesh = st.commit()