0

So i'm beginning to use three.js, trying to import a OBJ file using OBJLoader2.js locally (no npm). But when try to add import {OBJLoader2} from 'https://threejsfundamentals.org/threejs/resources/threejs/r115/examples/jsm/loaders/OBJLoader2.js';

It comes up with 404 not found errors for three.module.js,Mesh Reciever.js and OBJLoaderParser. And checking inside the OBJLoader2 file, it has imports for those files

import {
    FileLoader,
    Object3D,
    Loader
} from "../../../build/three.module.js";

import { OBJLoader2Parser } from "./obj2/OBJLoader2Parser.js";
import { MeshReceiver } from "./obj2/shared/MeshReceiver.js";
import { MaterialHandler } from "./obj2/shared/MaterialHandler.js";

Does this mean to use the OBJLoader2.js i need to use the whole three.js.master file then?. Because ive watched youtube tutorials and they seem to just copy and paste the OBJLoader2.js file inside their directory without errors. Thanks

SpikeThea
  • 340
  • 1
  • 3
  • 13
  • Wow. Right so it seems three.js.master in the website is the wrong one to download instead i downloaded three.js-dev and the latest OBJLoader contains no extra imports. Is this on purpose? – SpikeThea May 01 '20 at 23:47
  • 1
    Sorry, it's not clear to me how your local workflow looks like. But it does not matter if you use master or dev, both repositories should work. The youtube tutorials you are talking about probably use the global script version of the loader and not the ES6 modules version. I suggest you check out the latest official examples of `OBJLoader2` in order to understand how to use it: https://threejs.org/examples/webgl_loader_obj2 – Mugen87 May 02 '20 at 08:53

1 Answers1

0

I resolved the problem thanks @Mugen97. It is because I took the OBJloader.js file from jsm not the js folder.

SpikeThea
  • 340
  • 1
  • 3
  • 13