Skip to content

neurofuzzy/hatchplot3d

Repository files navigation

Hatchplot3D

A modern web app that allows you to create 3d scenes and project hatch lines onto objects in the scene. This is for use with an axidraw plotter that plots on black paper with a white pen. Since the pen is white, lines represent light areas. This includes a web-based 3d renderer that can take a scene and project hatch lines onto objects in the scene. The source of the projected lines will be a light source.

The algorithm for generating the path segments shall be:

For each light in the scene, prepare a hatching mask. This hatching mask will be an array of parallel lines that fill a circle that will be projected along the spotlight's light cone. For each line in the hatching mask, project the line outwards from the light source past the scene objects. This will result in a triangle in 3d space. To project onto objects, we will take this triangle and intersect it with every triangle face in each object's mesh in the scene. Filter out triangles in the scene that are facing away from the light source. Each intersection will either result in no intersection, a single point, or a line segment. Filter out everything except line segments. Repeat this process for every line in the hatching mask. Then, join adjacent line segments into paths. The final result for each light will be a set of paths.

Once we have spotlights that can project hatching masks onto objects, we'll want the ability to switch them from spotlight to directional light mode. Directional lights do not project a light cone from a point. Instead they project a square in the direction the light is facing. That means that instead of a triangle projected for each line, we will be projecting a plane. Then, instead of triangle-triangle intersection, we will be checking triangle-plane intersection between each triangle in the objects in the scene and the projected plane.

The renderer must be able to output vector SVG files suitable for plotting.

I want to be able to place the light in the scene and have it project onto surfaces. The lines would not pass through objects, but would be blocked so the objects cast shadows. The brighter the light, the more dense the hatch lines. To keep things simple, I'd like to start with a simple hatch which is just parallel lines, but I would like to be able to control the angle, so that I can combine lights with different angles to create crosshatch. I would like basic scene and camera controls with the ability to add and remove lights. We can start with a simple test scene with a box, sphere and light. I would eventually like to be able to import STL models.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages