Jump to content

New Gui in Babylon


Dad72
 Share

Recommended Posts

#7 - I had a bit of trouble with domImage too because new Image() has a naming collision, there is a (global?) alias for DomImage outside of the internal module declaration (var DOMImage = Image;).  When I moved the GUI code into my project I renamed Image class as ImageControl to avoid the conflict.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image

Link to comment
Share on other sites

2 minutes ago, brianzinn said:

#7 - I had a bit of trouble with domImage too because new Image() has a naming collision, there is a (global?) alias for DomImage outside of the internal module declaration (var DOMImage = Image;).  When I moved the GUI code into my project I renamed Image class as ImageControl to avoid the conflict.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image

Use babylon gui's namespace - new BABYLON.GUI.Image(), there can't possibly be a conflict.

Link to comment
Share on other sites

Actually, I do have an opinion about the class name, while we are on this topic.  I think choosing Image as the name of the class can lead to issues in the future.  If somebody does an ES6 import from babylon GUI like:
import { Image } from '/babylonjs/gui'
Then they will be unable to create an HtmlImageElement with the typical constructor new Image(height, width).  They would need to alias the import - ie: import { Image as GuiImage} from 'babylonjs/gui'.  So, I would have to say that I think that class name is maybe not the best choice.  Looks like it required also a global declaration, which could be clobbered.  I have it called ImageControl, so maybe not as good of a name.  It's always hard to name things...

Link to comment
Share on other sites

  • 4 weeks later...

Tell me please . I can not import BABYLON.GUI
Import * as BABYLON from 'babylonjs'; 
'Error'message:'Namespace' BABYLON 'has no exported member' GUI '

And when I started importing with help,

/// <Reference path = "../../../../ node_modules / babylonjs / dist / preview release / gui / babylon.gui.d.ts" />

I got an exception
  Error: Uncaught (in promise): ReferenceError: BABYLON is not defined

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...