Issue with babylonjs/core package and UniversalCamera


I have this error showing when creating a new UniversalCamera:
_this.inputs.addGamepad is not a function.

And indeed there is no addGamepad function if I go to the files

I had no issue with classic babylonjs packages.


Yep this is because of the TreeShacking. You need to import the Gamepad module


Ok so I have to make sure myself that all the modules needed are loaded. Understood! :wink:

But I wonder why UniversalCamera doesn’t load the Gamepad module then if it needs it?
Something linked to the backward compatibility as you mentionned in the documentation?


Nope this is actually a problem :slight_smile:
Pinging @sebavan

1 Like

In the meantime, you have the list of components here:


I imported the gamepad module but it doesn’t change anything.
import { Gamepad } from '@babylonjs/core/Gamepads/gamepad'

Here is an online repo: Hardwino Explanation


Yep I found the issue
will be on the next nightly (in a hour or so)


Thanks, I will test it tomorrow and keep you in touch.

1 Like

Hi @Deltakosh, how do I test the nightly update?

I realized i could simply use a freeCamera instead of the Universal. But then I have another similar error showing when I create new DefaultRenderingPipeline:
this._scene.enableDepthRenderer is not a function

And I can’t find that function in the babylonjs code in order to import it.


I found it here and now it works: Babylon.js/depthRendererSceneComponent.ts at master · BabylonJS/Babylon.js · GitHub


Verdict on treeshaking: I went from a little more than 3MB to a little less than 2MB! Awesome!

1 Like

this is gooood!


It seems that there is also a missing import with shadowGenerator:
“shadowGenerator.ts:719 Uncaught ShadowGeneratorSceneComponent needs to be imported before as it contains a side-effect required by your code.”

I made it myself for now. :wink: