Jump to content

[Solved] GUI error


Rook
 Share

Recommended Posts

I am getting the following error when trying to explore the GUI extension.  I think that I might be cross-pollinating between the new modular approach that just came out, and maybe old instructions for pre-alpha docs?

From http://doc.babylonjs.com/overviews/gui (I am showing my requires at the top, and line 61 from map.js):

var BABYLON = require('babylonjs')
var GUI = require('babylonjs-gui')
...
var gui = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI('UI')
// var gui = GUI.AdvancedDynamicTexture.CreateFullscreenUI('UI')
Uncaught TypeError: Cannot read property 'add' of undefined
    at new r (/home/rook/Documents/Projects/babylon-testing/node_modules/babylonjs-gui/babylon.gui.mi…:1)
    at Function.r.CreateFullscreenUI (/home/rook/Documents/Projects/babylon-testing/node_modules/babylonjs-gui/babylon.gui.mi…:1)
    at createScene (map.js:61)
    at map.js:68

I have tried both using

GUI.AdvancedDynamicTexture.CreateFullscreenUI()

and

BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI()

as you can see from the commented-out line.  Both error out.

What am I doing wrong?

Link to comment
Share on other sites

The new docs are up here, but are for imports:
http://doc.babylonjs.com/overviews/npm_support

Also, and importantly, are you using 3.1.0-alpha3.4 or 3.1.0-alpha3.5 - there are big changes there?

Here is a working example (using import not require):
https://github.com/brianzinn/create-react-app-typescript-babylonjs/blob/master/babylonjs-site/src/containers/home/index.tsx

I have seen the exact error you are getting it was something like xxx.onKeyboardDownHandler.add(...) - ensure you don't have another NPM package referencing an older version of babylonJS as a dependency (or redo your node_modules).  GUI won't reference a different version as it has a peerDependency to BabylonJS core.  Otherwise, do you have more of the stack trace - hard to see if there is something in your code or in babylonjs.

Link to comment
Share on other sites

There is something funky going on with my local version of 'npm', I think.  I was working to show something to Deltakosh on another issue, and when I deleted node_modules and rebuilt with 'npm install', then everything seemed to start working, so I am not sure if dependencies were horked up somehow or not.  But the rebuild worked when I tried it again on this issue!

I am adding this to my troubleshooting steps, as I've learned that it is not entirely reliable to just 'npm remove' and 'npm install' packages back to back.  I was doing this in troubleshooting a prior issue.  I am new to Node so forgive this firedrill.

 

 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...