I have ported most of “ln, The 3D Line Art Engine” by @FogleBird to javascript so it can be used on Turtletoy. The engine can create drawings of 3D scenes, that you can plot using a pen plotter, which naturally requires vector input.

Michael Fogleman created ln; a rendering engine that produces 2D vector graphics (think SVGs) depicting 3D scenes.

Each 3D scene consists of a collection of 3D objects of different shapes (basic shapes like cubes, spheres, cylinders and triangles are supported). An object has a position and scale, and texture: a set of lines on the surface of the object.

When the scene is “rendered”, all lines are split into tiny segments. A ray tracer is used to determine the visibility for each segment. By merging all visible segments back to lines, the full set of visible lines of the 3D scene is found.

The original engine is written in Go. The full source code can be found on GitHub: https://github.com/fogleman/ln.

I ported this engine to javascript so it can be used on Turtletoy. You can find the full source of some (ported) examples here:

Note: not all code is ported and not all code-paths are tested: there are probably still (a lot of) bugs left.

Another strategy for finding all visible lines of a polygon-based 3D scene is by projecting all 3D polygons to the screen and then draw them front-to-back. For each new line, an intersection test with the polygons already drawn determines the visibility of (parts of) the line. I have used this method for many of my turtles, including Cubic space division #2.

Similar posts

If you like this post, you may also like one of my other posts:

3D Line Art Engine (port)
Tagged on: