STLLoader createDefaultLight Crashes

I use alpha version of babylonjs and loaders

@babylonjs/core”: “4.1.0-alpha.17”,
@babylonjs/loaders”: “4.1.0-alpha.17”

When calling load function:

loader.load(scene, buffer, url);

I get the error:

core.js:4002 ERROR Error: Uncaught (in promise): TypeError: scene.createDefaultLight is not a function
TypeError: scene.createDefaultLight is not a function
at STLFileLoader.push…/node_modules/@babylonjs/loaders/STL/stlFileLoader.js.STLFileLoader.load (stlFileLoader.js:108)

Loader self works fine when I mock these functions on the scene:

(scene as any).createDefaultLight = () => { };
(scene as any).createDefaultCameraOrLight = () => { };

Looks like regression.


Can you try to add a line
import “@babylonjs/core/Helpers/sceneHelpers”;

in your code ? this should augment the module with the missing methods.

In the mean time I will add it for alpha 18 so that it is automatically imported by the stl loader.

Ah, thanks! It worked indeed. Looks much nicer without those mocked out functions :slight_smile:

Just started out with babylonjs, still a lot to learn… So far a really positive experience.

1 Like