I'm using the module version of three.js because I need to run imports from a client-side js file structure.
THREE itself works fine. But now I'm having the issue that I cannot use it in FBXLoader:
This is the import statement on my client-side rendering file:
import * as THREE from '/build/three.module.js';
import * as FBXLoader from '/js/loaders/FBXLoader.js';
This does not throw any errors.
Server-side, I'm using express to allow access to modules on client-side:
app.use(express.static(__dirname + '/public'));
app.use('/build/', express.static(path.join(__dirname, 'node_modules/three/build')));
app.use('/js/', express.static(path.join(__dirname, 'node_modules/three/examples/js')));
So far so good.
When I try to run, I get the following error:
Uncaught ReferenceError: THREE is not defined
<anonymous> http://localhost:3000/js/loaders/FBXLoader.js:22
<anonymous> http://localhost:3000/js/loaders/FBXLoader.js:3817
Any ideas what the problem is? There error is not in my code, this is something inside FBXLoader.js.
A file's imports are scoped to that file. It may be that FBXLoader.js isn't importing THREE and that's why it's undefined. Include in FBXLoader.js:
import * as THREE from '/build/three.module.js';