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:
<body> <script src = "../node_modules/three/build/three.js"></script> <script type = "module" src = "../public/mainpage.js"></script> </body>
To ->
<body> <script src = "../node_modules/three/build/three.js"></script> <script type="importmap"> { "imports": { "three": "../build/three.module.js", "three/addons/": "./jsm/" } } </script> <script type = "module" src = "../public/mainpage.js"></script> </body>
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.