# Lesson goal: Draw Polylines in 3D

Previous: Drawing lines in 3D | Home | Next: Introduction

In a previous lesson, you learned how to draw lines in 3D.

In this lesson, we introduce a many line (or "polyline") function that will draw many lines and connect each of them together. You just have to supply the sequential endpoints through which to draw the lines. This allows you to draw 3D "spaghetti" like graphics. The function is called line3dx and accepts an array of 3D coordinates.

line3dx({{x1,y1,z1},{x2,y2,z2},...,{xn,yn,zn}},color,thickness)

You can find a list of color codes here. The 3D drawing area will appear under your code-editor. You might have to scroll down to see it.

# Now you try. Mess around with the code a bit and see what you can come up with.

When using this function to draw, Lua has an interesting construct called a "table," which is an array of arrays, which is what the {{x1,y1,z1},{x2,y2,z2}...} actually is.

The point? If you define an empty array, like p={}, then you can "push" (x,y,z) points into it, one by one like this: table.insert(p,{x,y,z}). See the example. Dismiss.

Show a friend, family member, or teacher what you've done!