Babylonjs source code problem

I see that many classes in the source code use this way to extend the method, why not write the method directly into the class, but use this way to extend the class.

Hey @ZoeLeee , how are you doing.

@RaananW can correct if I’m wrong, but as far as I understand we can use this to “inject” methods into a class only if they are needed. If you don’t import this file, the Scene class will not have the _animate method.

To extend what @srzerbetto said, this is done to allow tree-shaking when importing individual files. It’s half-way towards full esm support.
It is not a problem and is 100% javascript- and typescript conform.

1 Like