I'm attempting to display a preview of an STL file using three.js. I came across a tutorial that seems to provide exactly what I need:
Tutorial
However, when I try to implement the code, I keep running into an error message saying
undefined is not a function (near '...loader.addEventListener...')
at the following line:
var loader=new THREE.STLLoader();
loader.addEventListener('load', function (event){
var geometry=event.content;
var material=new THREE.MeshLambertMaterial({ ambient: 0xFBB917,color: 0xfdd017 });
var mesh=new THREE.Mesh(geometry, material);
scene.add(mesh);});
I've double-checked that all the necessary files are included, but I can't seem to figure out what's wrong with my code. Is there an alternative approach I can take to achieve a simple preview of an STL file using javascript?