What's the best way to export the geometry for rendering in modern web front-ends?

Hi there,

I am using Geant4 as a computation engine for some 3D web application. I need to export the Geant4 geometry as a text file that can be sent to a modern web front-end for rendering purposes using, e.g., Three.js.

What would be the best export format to do that?

AsciiTree is kind of hard to parse, VRML is deprecated and while an XMLTree format is mentioned here in the docs, I couldn’t find any examples or code snippets for XML generation. Does that driver still exist anyway?

I would be grateful for any advice. For now, my best bet seems to be VRML despite its deprecation.

Yes, I think VRML2FILE is your best bet. We are working on a VTK driver - may be ready for the next release (December).

Thanks for you reply. How would a VTK driver help me? Isn’t VTK a software library? How is that related to exporting to text files?

Also, I forgot to mention that my system is a headless Linux server with no graphics card which might limit my options further.

I would recommend you to look at JSROOT project. They are able to render Geant4 geometry in the Web browsers.

Hi @Joerg ,

Your project of integrating Geant4 in 3D web application seems to be very interesting.
I have also similar idea (and prototypes) on my mind.
I saw that Geant4 was partially ported to webassembly (Compiling Geant4 to WebAssembly. Continuing from my previous post, we’ll… | by Saurav Sachidanand | Medium), so in principle it can also run on the client-side.

Can you write a bit more about your project ?

Kind regards,

So I have written a set of python classes to manipulate gdml, where manipulation includes access to all the 3D mesh data and exports to more modern 3D formats. If formats are missing assimp can be used. So it is usually very easy to export gdml from an application.

So the code is pyg4ometry and can be found on bitbucket.

To answer a question you asked previously. The VTK libraryis a scientific 3D rendering library and can export data to lots of modern formats like usd, obj, gltf etc.

Hi @lgrzanka,

I am writing a simulation software that can be used by engineers and sales people who are no experts in particle physics. The front-end will be a React-SPA, the back-end an ASP.NET web service that will start Monte-Carlo simulations in the Microsoft Azure Cloud possibly using Azure Batch. We haven’t started yet, but are still researching technology and prototyping.

1 Like

Thanks @sboogert, I will have a look at your Bitbucket repo.

Thank you @evc. I’ve only noticed your response about JSROOT now. Something like this image is exactly what I need.
However, I don’t know anything about ROOT. How would I export my Geant4 geometry to some ROOT file that can be loaded by JSROOT? Is there an easy way? Can you point me to some easy-to-understand tutorial?

I am not an expert in ROOT, but I know that ROOT can upload a geometry from GDML. Then, I believe, it can be converted to a ROOT file and uploaded to JSROOT. The best way to check is to contact the JSROOT developers, please see the following conversation at the ROOT forum:

Thank you very much.