2

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.

Kallol
  • 21
  • 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 Answers1

2

You can do it in 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