How to convert JSModeller jsonData for uploaded file to JSModeller body to use in JSM.ExportBodyToStl()
Requirement: option to upload stl/obj file, render it and at the end give an option to export to either stl/obj file
https://3dviewer.net/ has the option to upload files but does not have option to export to stl/obj
Problem: cannot get the body of the uploaded file.
// this code is from 3dviewer.net **impoterapp.js**
var processorFunc = JSM.ConvertFileListToJsonData;
if (isUrl) {
processorFunc = JSM.ConvertURLListToJsonData;
}
processorFunc (userFiles, {
onError : function () {
myThis.GenerateError ('No readable file found.');
myThis.SetReadyForTest ();
return;
},
onReady : function (fileNames, jsonData) {
myThis.fileNames = fileNames
// i get the jsonData here
//
// how do i convert jsonData to jsmodeller object
}
});
JSModeller has an export Option here http://kovacsv.github.io/JSModeler/documentation/demo/demonstration.html but all the examples they used here are created with generator function like JSM.LegoBrickGenerator(), JSM.ShapeGenerator (), etc
how do we generate/get/convert an stl/obj file to JSModeller Body ? as we need to pass body to ExportBodyToStl
example http://kovacsv.github.io/JSModeler/documentation/jsmdoc/index.html#ExportBodyToStl
JSM.ExportBodyToStl (body, 'JSModelerBody', false);
JSM.ExportBodyToObj (body, 'JSModelerBody', false);
above example of exportBody is from http://kovacsv.github.io/JSModeler/documentation/demo/demonstration.html