javascriptasp.net-core-mvc3d-modelstl-format

3D model does not render in ASP.NET Core MVC webpage with Stl Viewer Javascript PlugIn


I had this working with their remotely hosted option, but it was rather slow. I've wasted many hours trying to get the JS plugin to work.

I can't get the 3d model to display inside the div, as shown in their guide here: https://www.viewstl.com/plugin/#usage .

I have the div container on my page, as so:

<div id="stl_cont" style="various color and size stuff">Rendering 3D... Please Wait</div>

and I have all of the js files in a js folder off of wwwroot, so I have this:

<script src="~/js/stl_viewer.min.js"></script>

(If I view source, I can click on the link to the min.js and it will display in the browser, so I assume that path is valid as well)

I have this code next:

<script>
    var stl_viewer = new StlViewer(document.getElementById("stl_cont"),{models:[{ id: 0, filename: "https://www.exploredungeons.com/3dmodels/012/filename.stl", load_three_files: "js" }]});
</script>

I can look in view source and click the link for the STL file and it will download, so the path appears to be right.

I'm running ASP.NET CORE MVC if that helps any. When I was running the and pointing to the remote service, everything worked fine. I can't figure out what is missing.


Solution

  • Found the answer.

    The Stl Viewer expects all of the js files to be in the same folder as the page that's using it, which for an MVC app is impractical, so they also provide a parameter LOAD_THREE_FILES which you can use to specify the location of the js files it needs.