X_ITE is an open-source JavaScript library to display X3D (and a number of other formats) in a web browser, using WebGL. It was recently extended to import additional formats, and render them straight away or convert to X3D. The supported formats are now: X3D, VRML, glTF (GLB), OBJ, STL, and SVG.
There is an accompanying online converter to X3D and a command-line converter x3d-tidy that perform the conversion using X_ITE underneath.
In a way, this is similar to what we do in Castle Game Engine, where we also load everything (like glTF) to X3D nodes, give you an online converter and a command-line and GUI converter.
But there’s also a big added value: X_ITE supports SVG. SVG (scalable graphics, create it e.g. in Inkscape) gets converted into proper geometry in X3D, so it remains scalable and can be used as part of your 2D or 3D game in CGE! This is what I enjoy about being part of an ecosystem and open formats like X3D — we get new features “for free” thanks to cooperation with others.
Note that in the generated X3D file, all objects will be placed at the same depth, Z = 0, at least right now. You may have to fix it to avoid Z-fighting in case SVG layers overlap. For simple cases, it is possible to do this by just manually editing the X3D file in any text editor. Assigning meaningful names to your objects in SVG, e.g. using Inkscape “Object Properties”, also helps. I have done it with a non-trivial SVG file (our engine logo) and the manual effort was ~easy 🙂
See the result of my play in demo-models/svg. It shows how to fix Z, I also add a shader effect to discard pixels outside of a circle in the middle, to “cut off” stuff that should not be visible in a circular engine logo.
I encourage you to test the converter and explore X_ITE in general. Many thanks go to Holger Seelig for an amazing work on this!