I didn't understand some stuff, but I played around with it and I think I have a better understanding of this. So, to elaborate on how to make this, this is how I did it:
Create a scene with a
MeshInstance with a cylinder mesh 1 unit high and 1 unit wide, and save it. (Also with a material_override with relevant flags: e.g.
no depth test, etc -- don't use
fixed size, it will look wrong when the camera moves around).
To make it long enough to go from point A to point B you just scale it by the distance between A and B, and for the thickness you multiply the thickness value by a scalar to shrink it (e.g. 0.01), and use the result as the scale.
then you place the mesh at the center between the two points of the line and rotate the mesh appropriately.
I'm using the code below.
Note: the only way I figured out to rotate the mesh appropriately was using Spatial.look_at(), but for this I had to create the mesh in Blender, so that it extends along the Z axis by default (in Godot, cylinders are upright along the Y). This is not needed if you use CubeMeshes made in Godot, instead of cylinders (and you can easily make a CubeMesh through code).
onready var MeshObj := preload("res://resources/LineMeshInstance.tscn")
func line(a, b, color, thickness):
var line = MeshObj.instance()
line.material_override.albedo_color = color
line.scale = Vector3(0.01*thickness, 0.01*thickness, a.distance_to(b))
line.look_at_from_position((a+b)/2, b, Vector3.UP)
I haven't tested whether the material and mesh need to be made unique (using