I've been trying to set up a testing enviroment for the purpose of learning ThreeJS. When trying to import the FBXLoader from ThreeJS I've encountered a problem. For some reason i get the following error:
Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".
I've tried using every possible path format i could think of but it doesn't seem to solve the problem. The same file format i'm currently using seems to work perfectly fine for importing three.module.js though.
The code in my main.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
</style>
<!-- <script src="node_modules/three/build/three.js"></script>
<script src="node_modules/three/examples/jsm/loaders/FBXLoader.js"></script> -->
</head>
<body>
<script type="module" src="/node_modules/main.js"></script>
</body>
</html>
The code in main.js (everything else is commented out to solve this error):
import { FBXLoader } from "./three/examples/jsm/loaders/FBXLoader.js"
What am i doing wrong?
I found out that i need a bundler for this import. I installed webpack, and now it seems to be working.