Adding line thickness with shadows for visualising 3D printing layers


I have been trying for a while now to figure out a way of adding thickness to lines that can receive shadows and look like solid objects.

The application is for an online 3D printing platform so I am trying to visualise the sliced geometry that is comprised of lines, similar to how other slicing software handles this, such as cura as shown in this image.

Generating mesh geometry from these lines would be most probably problematic as in some cases there are thousands of a lines in a single model so it will be too heavy. Any suggestions would be greatly appreciated!

Well, the only way of consistently rendering such wide lines is the usage of meshes. I suggest you give the wide line implementation of three.js a try since it is focused on performance. For example it uses instanced rendering to optimize the number of drawcalls.

However, the respective line material does not support shadows so this might be a blocker for your use case. Alternatively, you can try to use TubeGeometry with a lit material (like MeshPhongMaterial) and create custom meshes from it. This will be however more expensive to render than using wide lines.