Construct 3D geometry with PHP?

485 Views Asked by At

I need to construct 3D models for use with Three.js, but I need to do CSG (Constructive Solid Geometry) operations on them too. I managed to use the ThreeCSG.js library for this, but I find this to be quite slow (about 5 seconds to slice about 30 holes from a complex shape).

Somehow I need to cache the geometry that is constructed, but since the construction of 3D geometry now happens only on the client side in the browser (with Javascript) I have no way of doing this on the server, which uses PHP.

  • Are there any 3D libraries in PHP (that can do CSG as well) ?
  • What's the best way to pre-calculate 3D models for later use in Three.js ?
1

There are 1 best solutions below

0
On

I highly doubt you will find good 3D libraries in PHP. If you can't install other software on the server, you could generate it on client side first run and send it to server. Subsequent request would then be served that cached file. I do something like this.

Take a look at http://mrdoob.github.io/three.js/examples/js/exporters/GeometryExporter.js . There is also ObjectExporter and SceneExporter. You can use GeometryExporter to save the generated geometry to Three.js JSON

Three.js r59