Web3DConsortium / X3D-Edit

X3D-Edit is an Extensible 3D (X3D) Graphics authoring tool for simple error-free creation, editing, validation and viewing of X3D scenes for interactive Web-based visualization. X3D-Edit runs as a standalone application or Netbeans plugin. The X3D file format is an advanced XML version of the original VRML97 international standard.
https://savage.nps.edu/X3D-Edit
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

OpenSCAD format #10

Open Chris2011 opened 2 months ago

Chris2011 commented 2 months ago

I was searching or also implementing for an OpenSCAD for NetBeans. I know that there is an IntelliJ plugin which just renders the element out, call an HTML file within a WebView and renders the result. I like the idea but this brings some problems with it, we always need to render the element which can take to long.

So I was searching for a more native way like the OpenSCAD Tool is doing. Long story short, OpenSCAD is not X3D right? But is there anything that we can reuse to also handle OpenSCAD? I'm just searching for a renderer of saved OpenSCAD files. Maybe you can open the discussion section to make this a discussion instead of an issue. If there is smth possible, somehow.

vincentmarchetti commented 2 months ago

OpenSCAD is able to export to STL, and there are STL viewers implemented in Java (example : https://github.com/ag88/stl-viewer ). Perhaps the shortest path to creating NetBeans viewer for OpenSCAD would be that route. As well, there may be open source javascript -based STL viewers that could be used in WebView as you propose. Finally, there are ways to generate X3D from STL but I am not aware of STL to X3D conversion implemented in Java.

Chris2011 commented 2 months ago

The problem with exporting is that it take to long for just the preview. I guess that the preview of the OpenSCAD application is not doing this at all. I also mantioned the STL WebView thing because this is exactly what IntelliJ is doing, but the problem is again you need to export/generate the whole file first to STL and if you have a big one, everystime you save it it needs to be converted which is not user friendly. It needs to be changed instantly like the openScad application is doing it.

This is why I'm asking whether your plugin can handle that too or not but I guess not because it is the wrong use case here. I was just thinking about it.

brutzman commented 2 months ago

Thanks for excellent ideas. If there is suitable open-source STL-import source code that can produce X3D (for example, a simple IndexedFaceSet or perhaps one of the Triangle nodes) then I will be happy to adapt and integrate it into X3D-Edit. It will then be easy for X3D-Edit to optionally add a full scene graph around those triangles, so that launching X3D rendering by another player was the very next step.

The stl-viewer source code looks simple enough, it reads STL into java3d structures. Am expecting that similar mappings for X3D seem likely. The stl-viewer file loading and parsing of the STL might be reused, which can keep things simple.

Another approach might be to tackle the OpenSCAD format itself, though that is likely much more involved. For someone conversant with OpenSCAD source code, still-another alternative path would be to add X3D export to its export capabilities. If we got the STL-to-X3D pattern correct, then adding that might be a straightforward adaptation of the OpenSCAD STL exporter.

Again thanks for considering the possibilities.