1

I'm currently developing a Django app that allows students to programmatically develop SVG graphics. They can code Python in their browser with ACE editor. The code is executed on the server, stored in a database and the generated SVG (custom library) returned and displayed. An example code that displays a filled ellipse looks like so:

graph.draw(Circle(cx=0, cy=0, r=20, fill="lime").scale(2, 1)

Now I'm wondering, how I could extend this app to do some 3D. I stumbled over X3Dom, which seems promising and not too hard to generate and I could write another lightweight pythonic library for this. But, it doesn't seem to do CSG (constructive solid geometry) which is major drawback.

Any hints in what direction I should investigate for some 3D web technology that allows easy 3D scene generation with server-side python and that implements CSG?

NB: OpenJSCad is simalar to what I'd like to achieve, except that my solution allows for classroom collaboration and it must expose Python to students as the programming language. The aim is to spice up the teaching of Python programming with graphics.

Marc Koch
  • 11
  • 1

2 Answers2

0

I believe I used three.js to do CSG a while back. There used to be an example online. You are right that X3D does not do CSG. I was doing cross sections of the earth and found a way with X3D. You might be able to use VPython or brython in the browser if your worried about Python not running in the browser. I’ve only brython for a short time testing another person’s project and vpython not at all.

If you’re doing something like inverseCSG or CSGNet, is your class available online?

In other words, maybe try to find a Python library that does CSG instead searching for a rendering engine in JS. Don’t view the browser as limited to JS.

I only found three.js when I was looking.

Maybe search for a solution which is not a solid solution.

John Carlson
  • 321
  • 1
  • 13
0

try checking out the library "trimesh" for python which relays mainly on watertight stl files, but allows you to do some boolean operations for CSG. You can substract one file from the other, extended and find the intersection. Plus, it has some primitive functions directly like cylinders and spheres.