Uncaught TypeError: n.getEngine(...).getInputElement is not a function

Hi, I am using BabylonJS to build 360 video player. And my player could work. However, recently I get an error which prevents my player from playing 360 videos. The error is:

Uncaught TypeError: n.getEngine(…).getInputElement is not a function
at new e (babylon.gui.min.js:16)
at Function.e.CreateFullScreenUI (babylon.gui.min.js:16)
at createScene (my javascript)

This error prevents the player from rendering video, but sound of the video can be played. Since when I used this function at the very beginning it could work, I think this babylon.gui.min.js must have been updated or modified. So please help me to solve this problem.
Thanks in advance!

We would need a repro in order to help here as it sounds impossible without it. Could you create a little playground for it ?

It looks like your scene does not have an associated engine which is really strange

Thanks for responding. Please check the repo: Babylon.js Playground

The error occurs at line 42, which previously worked very well.

But here this is not code compatible with the playground, the idea is that you create a small easy way for us to reproduce the issue.

The playground already defines a number of things for you (canvas, engine, …).

Here’s your sample updated so that it works in the playground:


The video does work here.

1 Like

Thanks. But I need those things for my own webpage. Also, there are more than one player in a page, so I need to parse those parameters to that function. Even though I change the line 42 from the original one to the new one, that problem still exists. So I decided to delete that line and not use 2D GUI currently.

I’m having a very similar issue!

I’m using TypeScript to write my code and Webpack to bundle it, and the webpage worked fine until I tried to add the babylonjs-gui package and use AdvancedDynamicTexture. Ever since then I get the same uncaught TypeError that you do.

I’m still looking for a solution so I’ll let you know if I find one

We need a repro to be able to help here. Unfortunately without it, it is hard to determine if it is an error in your code or in your webpack config :frowning:

I fixed my issue! I wasn’t passing my scene to the constructor of AdvancedDynamicTexture.CreateFullscreenUI.

So my code used to say: AdvancedDynamicTexture.CreateFullscreenUI("help"); (which didn’t work)
And it now says: AdvancedDynamicTexture.CreateFullscreenUI("help", undefined, this.scene); (which works!)

Hopefully that helps

1 Like

For reference, the fixed file is on my GitHub. (I followed the BabylonJS/ReactJS guide, then converted it into TypeScript, added my own functionality, and changed the existing boilerplate code).

I have the same problem, even when I explicitly pass in the scene.
What worked for me is setting the input element for the engine (but it is a big hack so I’m not happy with it):

const canvas = document.getElementsByTagName('canvas')[0]
const engine = new Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true })
engine.getInputElement = () => canvas

I had this issue, what worked for me was make sure both the babylonjs version and babylonjs gui version were up to date. I had an old version of babylonjs, and a newer version of babylonjs gui :grin: