Stl Viewer Javascript Plugin
created on
Thursday, 12 January 2023
edited on
Sunday, 18 January 2026
by
Stefan Trucker
Allows embedding binary/ASCII .stl, .obj, and 3mf files on a webpage.
Usage
Ideally, insert it in the header, but insertion in the body is also possible
<script src="/stl_viewer.min.js"></script> Code in Ablage kopierenCreate an element in the page content that will contain the STL viewer and give it an ID:
<div id="stl_cont"></div> Code in Ablage kopierenCreate a new instance of Stl Viewer (simplest initialization - read and display the STL file named "mystl.stl"):
var stl_viewer = new StlViewer(document.getElementById("stl_cont"), { models: [ {id:0, filename:"mystl.stl"} ] }); Code in Ablage kopierenIf you want to embed 3mf files, it is necessary to include an additional script
var stl_viewer = new StlViewer(document.getElementById("stl_cont"), { .... jszip_path: "//jszip.min.js", jszip_utils_path: "//jszip-utils.min.js" }); Code in Ablage kopierenWerbung