line3d.gd 571 B

12345678910111213141516171819202122
  1. extends MeshInstance3D
  2. func _ready():
  3. set_mesh(ImmediateMesh.new())
  4. var material := StandardMaterial3D.new()
  5. material.flags_unshaded = true
  6. material.albedo_color = Color.WHITE
  7. set_material_override(material)
  8. func draw_path(path):
  9. var im: ImmediateMesh = mesh
  10. im.clear_surfaces()
  11. im.surface_begin(Mesh.PRIMITIVE_POINTS, null)
  12. im.surface_add_vertex(path[0])
  13. im.surface_add_vertex(path[path.size() - 1])
  14. im.surface_end()
  15. im.surface_begin(Mesh.PRIMITIVE_LINE_STRIP, null)
  16. for current_vector in path:
  17. im.surface_add_vertex(current_vector)
  18. im.surface_end()