spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.14k stars 381 forks source link

"MeshLine is not a constructor" when using require() #40

Open CarlosSaulMenem opened 7 years ago

CarlosSaulMenem commented 7 years ago

When I do this:

var THREE = require('three');
var MeshLine = require( 'three.meshline' );
var line = new MeshLine();

Which is what the readme says, right? Well, I get Uncaught TypeError: MeshLine is not a constructor

Both modules are installed and load properly. I noticed that some other THREE modules I've used ask for THREE to be sent as a parameter like this var name = require('name')(THREE); and I have a feeling it has to do with Line 9 of MeshLines not properly detecting my code's instance of THREE and requiring it's own

line 9: var THREE = root.THREE || has_require && require('three')

spite commented 7 years ago

I don't use the module version. Back when i built that package, I checked with some people that if it was working as expected. If you can figure out what needs to be fixed, I'll update the package.

mcrawshaw commented 7 years ago

Try:

var MeshLine = require( 'three.meshline' );
var line = new MeshLine.MeshLine();
var material = new MeshLine.MeshLineMaterial();

Global exports aren't working in your environment. Library should be updated.