I want to convert .stl files to a .x3d file so that it can be used by HTML5 supported browser. I have figured out way to display x3d in HTML5 but struggling with converting .stl files to .x3d format using either Java or Javascript. Please help.
Asked
Active
Viewed 853 times
2
-
Check https://openjscad.org/, that page can receive stl and x3d files and it is open source – Pablo Lozano Jun 02 '17 at 15:31
-
Descriptions and links for numerous tools for X3D import/export/conversion are maintained at [X3D Resources: Conversions and Translation Tools](http://www.web3d.org/x3d/content/examples/X3dResources.html#Conversions) – Don Brutzman Sep 04 '17 at 19:21
1 Answers
2
You can do it in javascript by using the tools provided by jscad:
const stlDeSerializer = require('@jscad/stl-deserializer');
const x3dSerializer = require('@jscad/x3d-serializer');
const rawData = fs.readFileSync('PATH/TO/file.stl');
const csgData = stlDeSerializer(rawData);
const x3dData = x3dSerializer(csgData);

Pablo Lozano
- 10,122
- 2
- 38
- 59
-
Is there also a simple way of writing the file out? Thanks in advance. – Pablo Jeken Rico Apr 07 '21 at 13:20