-
Notifications
You must be signed in to change notification settings - Fork 81
How to use OBJLoader? #15
Comments
Not at all. Sadly, this is a common problem using the examples code in this type build system. The README should make a mention of this. I've used this package in the past to resolve your issue : https://www.npmjs.com/package/three-obj-loader |
Hmmm interesting. I tried to install that package, too, and seemed to have largely the same issues. I might need to get a bit more familiar with threejs itself I suppose. |
Try this :) import { Group, ObjectLoader } from 'three';
import MODEL from './flower.json';
import * as THREE from 'three';
import OBJLoader from 'three-obj-loader';
export default class Flower extends Group {
constructor() {
const loader = new ObjectLoader();
super();
this.name = 'flower';
const x = OBJLoader(THREE);
const y = new THREE.OBJLoader();
console.log(y.load)
loader.load(MODEL, (mesh)=>{
this.add(mesh);
});
}
} logs..
|
I think I see what you're getting at, although the example above is still trying to import a JSON model, not an Using your example, I got a bit further (no compile or console errors any more, at least):
Now getting a 404 on my |
If you 'import' the obj that will give you a URL to load. |
Wonderful, thank you! (I had thought somehow that importing from a non-JS file would throw parsing errors, but it seems my understanding of Webpack might be a little deficient.) |
Forgive me if this is a trivial question, but I am trying to load an OBJ from within the three-seed structure, in a similar way to how the standard examples use
ObjectLoader
, but can't quite figure out how to get it done.I import what I assume is the correct loader:
But if I try
Then I get the error:
The text was updated successfully, but these errors were encountered: