Issue with babylonjs/core package and UniversalCamera

#1

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.

#2

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

#3

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?

#4

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

1 Like
#6

In the meantime, you have the list of components here:
https://doc.babylonjs.com/features/es6_support#faq

#7

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

#8

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

#9

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

1 Like
#10

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.

#11

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

#12

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

1 Like
#13

this is gooood!

#14

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: