How to load OBJ and MTL?

What I’ve already done:

I’ve been reading some docs and examples from threejs.org, here we import files
directly with URLs, and I need to use them like any other dependency.

So I installed three (as always) and three-obj-loader and followed the instructions…

But clearly I’m doing something wrong. :sweat_smile:

What I need:

I’d appreciate some steps/guide to use OBJLoader and MTLLoader as dependencies
(if it’s possible).

three-obj-loader should actually be deprecated since you can import OBJLoader and MTLLoader from the original npm package like so:

import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader.js';
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader.js';

This is explained in the following guide (section Importable Examples): https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules

So there is absolutely no need for such external npm packages like three-obj-loader anymore. All example code is available as ES6 modules in the original three package.

1 Like

Look there

2018:

http://discourse.threejs.hofk.de/2018/index2018.html

in the middle of the page
http://discourse.threejs.hofk.de/2018/loadOBJ/loadOBJ.html

I just realized that all those examples are directly included in the package of three. So, separately npm package are absolutely unnecessary, as you well said.

It was my ignorance and a deprecated package together. :sweat_smile:

Thanks for the help, and have a grate day. :+1:

Thank you too. :+1:

These packages have unfortunately caught out a lot of people. I’ve reached out to the authors of several packages by opening issues on their github repos, but only one dev has responded so far :slightly_frowning_face:

Same for three-full. It has still over 2000 downloads per week! Unfortunately, the author does not react on my comment as well…

1 Like

I asked a bit more pointedly, hopefully that will get his attention.

1 Like