Javascript-based CAD

I've spent this week working on a group art project. My contribution to this project will be a printable 3D model. If I have time I'll work on enabling an integration with Shapeways as well to make printing easy, and maybe even pay for hosting.

I'm making a grave marker and decided I wanted to be able to make engraved text. The tools I've used in other projects BYO-triangle-STL, or VRML, were in adequate for the task, so I had a look around. This project is part of SUSE hackweek so I stuck to open source projects--this narrows the field in 3D modeling quite a bit.

I found OpenJSCAD.org to have exactly what I needed, given that one of these examples was a customizable name plate. It was nice knowing I could get there.

The shape manipulation code is dead simple and made my life easy. The text creation tools are too simple and I spent some time with plain-old trial and error developing a simple text layout. Once I had the basics of keeping track of a cursor through space I didn't have much problem laying out the design. I even had fun implementing some word wrap code for longer inputs.

Here's some basic jscad code to build a tombstone:

function createStone() {  
    var objects = [
        CSG.cylinder({start:[0,0,-4], end:[0,0,4], radius: 1}).scale([30,10,1]),
        CSG.cube().scale([30,40,4]).translate([0,-40,0]),
        CSG.cube().scale([32, 2, 7]).translate([0, -82, 0]),
        CSG.cube().scale([34, 2, 9]).translate([0, -86, 0])];
    return objects;
}

Here's a screenshot of a final model:

Most of the 250 lines of code to make that are text handling. If I was going to do more I could convert this into a general purpose text layout library. We'll see if OpenJSCAD.org has staying power for me.

I'll link to the final project when it launches.