How to convert .stl files into a .x3d file using Java / Javascript

892 views Asked by At

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.

1

There are 1 answers

1
Pablo Lozano On

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);