How to use a 3D stl viewer on Ruby on Rails

Viewed 200

I found this javascript plugin that allows to visualize STL files in 3D: https://www.viewstl.com/plugin/ The example works very well, the problem is that I can not find how to put that into a rails template. I took all the javascript files to my assets/javascript, then I added the respective '// ​​= require' in aplication.js, I took the small script with the div:

<div id="stl_cont" style="width:500px;height:500px;margin:0 auto;"></div>
<script>
  var stl_viewer=new StlViewer(
    document.getElementById("stl_cont"),
    { models: [ { filename:"viewstl_plugin.stl" } ] }
  );
</script>

and put them in my template but it does not work. Watching the console of my browser I found the following error: ReferenceError: importScripts is not defined. I saw that it has to do with web workers and that an importScripts only works inside them but this problem does not appear in the test.html so I guess something I'm doing wrong when putting them in rails that blocks or prevents the correct operation of importScripts.

I apologize for my lack of fluency in English.

Help :(

0 Answers
Related