THREE.MeshLine icon indicating copy to clipboard operation
THREE.MeshLine copied to clipboard

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

Open CarlosSaulMenem opened this issue 8 years ago • 2 comments

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')

CarlosSaulMenem avatar Apr 03 '17 17:04 CarlosSaulMenem

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.

spite avatar Apr 03 '17 20:04 spite

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.

mcrawshaw avatar Apr 06 '17 10:04 mcrawshaw