When importing SceneLoader directly from import { SceneLoader } from '@babylonjs/core/Loading/sceneLoader';
an exception is thrown:
TypeError: Cannot read property 'plugin' of undefined
at Function.SceneLoader._loadData (sceneLoader.ts:364)
at Function.SceneLoader.ImportMesh (sceneLoader.ts:602)
at sceneLoader.ts:644
at new Promise (<anonymous>)
at Function.SceneLoader.ImportMeshAsync (sceneLoader.ts:643)
at AssetsManager._callee$ (assetsManager.ts:5)
at tryCatch (runtime.js:62)
at Generator.invoke [as _invoke] (runtime.js:288)
// ...
importing SceneLoader like import { SceneLoader } from '@babylonjs/core/Loading'; fix the problem.
I ll fix it ASAP thanks for reporting
@sebavan thanks you're my man.
btw, same problem with: import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
"Import ShadowGeneratorSceneComponent before creating ShadowGenerator." is thrown.
This one is expected and even a custom error message as shadow generator needs the component being loaded and reversly so this creates a naughty circular dependency. we will soon introduce some smaller chuncks like workloads to simplify those.
For instance everything shadow related will be in a shadow module, so when you import from it, it will import all the necessary side effects on your behalf. It should simplify a lot the usage. We are currently finishing to abstract the bigger chunks before this.
It will definitely be in 4.0 with the correct list of side effects :-)
@kutomer about the first one, it is kind of expected as well as to allow tree shaking we can not import the specific loader on your behalf (gltf vs obj vs .babylon)
You will need to import the loader of you choice for side effect only like:
import "@babylonjs/loaders/glTF";
https://doc.babylonjs.com/features/es6_support#loaders
I will add nevertheless a clearer error message
O.K changed to:
import '@babylonjs/core/Loading/Plugins/babylonFileLoader';
import { SceneLoader } from '@babylonjs/core/Loading/sceneLoader';
Thanks again.
Yup exactly what will happen in the workload maybe i could reexport sceneLoader in babylonFileLoader to do:
import { SceneLoader } from '@babylonjs/core/Loading/Plugins/babylonFileLoader';
or something along those lines ?
Would that be clearer ?
closing for now as not a bug per se but we are working towards simplifying usage of the es6 version now
Not sure if it will be clearer, I guess an indicative error msg will suffice :)
ok perfect thanks: https://github.com/BabylonJS/Babylon.js/pull/5761/files#diff-ec57518e0799212a83c8752a69d717a5R372
Still having this issue with version 4.0.3, resolved it using the fix from @kutomer .
Most helpful comment
O.K changed to:
Thanks again.