I have an Angular application with a basic Three.js setup. I use Bazel build and run the app. Everything works fine until I try to import the OBJLoader2
from three/examples/jsm/loaders/OBJLoader2
.
const module = await import('three/examples/jsm/loaders/OBJLoader2')
const loader = new module.OBJLoader2()
The code snippet above doesn't work with the ts_devserver. I get this error in the browser console:
GET http://localhost:4200/three/examples/jsm/loaders/OBJLoader2.js net::ERR_ABORTED 404 (Not Found)
Error: Script error for "three/examples/jsm/loaders/OBJLoader2"
at makeError (ts_scripts.js?v=03400874:175)
at HTMLScriptElement.onScriptError (ts_scripts.js?v=03400874:1745)
So the ts_devserver cannot find the imported script. But running the app in production works totally fine.
Minimal Reproduction
You can try it yourself: https://github.com/drakery3d/angular-bazel-three-starter/tree/ac0c89abf267af094a555c5e4867a46e2ee33a8f
Just run yarn install
and then yarn dev
(it causes the error in the browser console @ http://localhost:4200). And not that yarn pwa
@ http://localhost:8080 works just fine!
from Cannot Import from Three.js Examples (Script error for "three/examples/jsm/loaders/OBJLoader2")
No comments:
Post a Comment