I am trying to install the latest version of 3js.
I go by the directions on the 3js website, here:
https://threejs.org/docs/index.html#manual/en/introduction/Installation
I am doing part: “Install from CDN or static hosting”.
I have downloaded the library onto my computer, so I am referring to my own file there.
Using this, I can run 3js code.
But the problem is, if I try to run that given code in it’s own file, like this:
<script src="./thecode.js"></script>
I get error:
Uncaught ReferenceError: THREE is not defined
It is like it’s not recognizing threejs at all, in that file.
But it recognises threejs, if I just keep it in the index.html.
But I can’t just be programming in the index file forever.
How do I get it to recognize threejs in the file?
I have also tried adding type=“module”, to the reference, to no avail.