A little new to Three.JS & was trying to work on a project as a hobby. I am trying to make a Pokemon Chess Game. I used pre-existing .SLL files for the chess asset pieces.
I keep having issues trying to get it to load properly though. I am constantly getting this error:
Uncaught TypeError: Failed to resolve module specifier “three”. Relative references must start with either “/”, “./”, or “…/”.
I have double checked to make sure all the files are in their right directory. I have everything hosted on GitHub if you guys want to take a peak:
Maybe you should do yourself a favor and not host three.js files in your repository.
Since you are hosting your assets on GitHub then maybe try continue working with the attached standalone HTML file (do note that it is using tabs instead of spaces).
to make it very short, don’t go into web dev without knowing tooling and packages. managing dependencies by hand, copying files around, we used to do that 20 years ago, but nothing works this way today. it has become so much easier.
The STLLoader imports stuff from other files of Three.js and expects that there is import shortcut named three. You do not define it (if you used package manager like vite it will be defined automatically). To resolve the issue you have to define it manually. Here are the two changes:
Change 1
Define three with import map in the <head> section of your index.html file: