I am currently trying to load a .obj model into my three.js project. I feel like I have all the code correct becasuse my code compiles without any errors, but when I go to Google Chrome’s console it is giving me this error. .
mainpage.html
mainpage.js
Advertisement
Answer
Try changing:
JavaScript
x
7
1
<body>
2
3
<script src = "../node_modules/three/build/three.js"></script>
4
<script type = "module" src = "../public/mainpage.js"></script>
5
6
</body>
7
To ->
JavaScript
1
17
17
1
<body>
2
3
<script src = "../node_modules/three/build/three.js"></script>
4
5
<script type="importmap">
6
{
7
"imports": {
8
"three": "../build/three.module.js",
9
"three/addons/": "./jsm/"
10
}
11
}
12
</script>
13
14
<script type = "module" src = "../public/mainpage.js"></script>
15
16
</body>
17
Basically, you’re adding an Import Map. I’m not sure however if this code that I just typed, will fix your problem since you just sent screenshots of the code, instead of the actual code. For this reason, i’ll be linking you a website that explains more about Import Maps and once again the link that @Rabbid76 commented, please also take a look at that one.