Stream: brlcad

Topic: running librt as a VS Code extension


view this post on Zulip Raghav Sharma (Jul 03 2026 at 08:03):

Hi so I was just testing my CAD MCP server while adjusting things in VS code and I realised there was no quick way to preview which models I might wanna test on.

So in an attempt to build a small utility for myself I thought of building a VS Code extension to preview .g databases within my IDE so I can preview models and even inspect changes made by my MCP in a headless mode without MGED open all the time.

I ended up realising .g files aren't as simple to parse as some format like obj or fbx as the librt deps are bundled quite tightly (the primitives are parametric and the wireframes don't exist until the plot routines generate them)

So I ended up bundling some parts of librt (the v5 object framing, comb tree walking with matrices, the region-id colortable, and the plot routines for arb8/tgc/ell/tor/bot (which covers around 99% of the solids in share/db)) into WASM and then strap that to 3js to make a bundled viewer within a VS Code extension

and funnily enough it works

image.png

Right now its some certain sections of librt that I surgically extracted with the help of claude just to make the line rendering work for previews.

Its quite amusing that a lot more of librt could be ported into the editor this way.

view this post on Zulip Raghav Sharma (Jul 03 2026 at 08:06):

(I also just got access to claude fable 5 and I wanted to take it out for a test drive so this little extension was a low risk way to play around with it)

This was just a little utility I built for a personal grievance of mine (I just needed a quick way to eyeball models and the changes that my MCP is making without switching to MGED again and again) but if this seems useful to anyone else I'd be happy to put this as a VS code extension on the store

view this post on Zulip Raghav Sharma (Jul 03 2026 at 08:18):

output.mp4

view this post on Zulip Raghav Sharma (Jul 03 2026 at 08:40):

might end up extending it with some more functionality (like a toggle for orthogonal/perspective view or some tree like GUI to inspect the nesting structure of the components)

view this post on Zulip Sean (Jul 10 2026 at 06:09):

not gonna lie, that's pretty sweet

view this post on Zulip Sean (Jul 10 2026 at 06:09):

how does it decide which top-level?

view this post on Zulip Raghav Sharma (Jul 10 2026 at 11:02):

basically the same thing tops does with anything that isn't referenced by any other comb being a top. It does one pass over all the combs in the file, marks everything that shows up as a member, and whatever's left unreferenced gets drawn. Hidden objects and attribute-only stuff like _GLOBAL get skipped, and cyclic references get pruned (havoc.g taught me that one the hard way with some solids getting drawn 2000+ times before I added it).

also tested it alongside the standard mged tops command for consistency

view this post on Zulip Raghav Sharma (Jul 10 2026 at 11:04):

I'm handling the database format parsing in C while the js side just gets handed a bunch of polylines it has to draw. the js side never sees the database format or librt functions themselves as they are contained within the WASM module

view this post on Zulip Raghav Sharma (Jul 10 2026 at 15:40):

(deleted)

view this post on Zulip Sean (Jul 11 2026 at 20:35):

Raghav Sharma said:

This was just a little utility I built for a personal grievance of mine (I just needed a quick way to eyeball models and the changes that my MCP is making without switching to MGED again and again) but if this seems useful to anyone else I'd be happy to put this as a VS code extension on the store

Raghav, I totally think you should put it in the extension store. I know of lots of folks that would love to have that capability at their fingertips.


Last updated: Jul 25 2026 at 01:46 UTC