0
votes

I am new to three.js and have been struggling to get things to work. I am trying to import the mtlLoader module that comes with the latest three.js-master repository from the three.js site. I get this error when trying to import the mtlLoader module into my script-

Uncaught SyntaxError: The requested module '../dap/build/MTLLoader.js' does not provide an export named 'MTLLoader'

I was looking at the mtlLoader code and it doesn't have an exporter from what I see, but all the examples I have found from the three.js site imports that module using code similar to what I have here-

        <script type="module">
        import * as THREE from '../dap/build/three.module.js';
        import { MTLLoader } from '../dap/build/MTLLoader.js';
        </script>

I am using the mtlLoader that comes in this repository I downloaded and I am not sure if I am missing a step. I am also new to using modules in my Javascript so any clarifications would be greatly appreciated.

1
For anyone who has a similar issue I needed to have all of the files from the repository on the server and not just the ones I needed. - Aunger1205
That's correct because MTLLoader is a module in this case and thus looks for three.module.js under a certain path. BTW: Consider to add your comment as an answer. - Mugen87
I will do that thanks for the explanation of why btw. I just had a feeling I needed all of the repository and I didn't know exactly why. - Aunger1205

1 Answers

1
votes

For anyone who has a similar issue I needed to have all of the files from the repository on the server and not just the ones I needed.