Text inside an embedded scene

Hey everyone, I’m trying to display information in form of a text inside my babylonjs scene which is wrapped inside an html using the tag

https://playground.babylonjs.com/#XCPP9Y#9012

But I’m getting error at line 22. Anyone can help me?

Uncaught TypeError: Cannot read properties of undefined (reading ‘AdvancedDynamicTexture’)
at SquareColumn.displayInfo (structural.js:30)
at drawColumn (structural.js:53)
at HTMLLIElement.onclick (index.html:159)

Seems to be working for me:

image

Can you try a hard refresh?

The playground works, my code which runs an embedded scene of BabylonJS gives me this error.

    displayInfo(){
        var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");

        var rect1 = new BABYLON.GUI.TextBlock();
        rect1.text = "Olá";
        rect1.width = 0.2;
        rect1.height = "40px";
        rect1.cornerRadius = 20;
        rect1.color = "Orange";
        rect1.thickness = 4;
        rect1.background = "green";
        rect1.hoverCursor = "pointer";
        rect1.isPointerBlocker = true;
        advancedTexture.addControl(rect1);   
    }

Uncaught TypeError: Cannot read properties of undefined (reading ‘AdvancedDynamicTexture’)
at SquareColumn.displayInfo (structural.js:21)
at drawColumn (structural.js:45)
at HTMLLIElement.onclick (index.html:159)

Feels like the change i made last Friday. What version of babylon are you using? what version of the GUI are you using? are they both the same?

Babylon.js v5.0.0-alpha.48

not the preview CDN?

<script src="https://preview.babylonjs.com/babylon.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>

you will need to use the same version for all packages you are using. if you are using the preview cdn, please use the preview cdn to all of your packages. change the url from cdn.babylonjs.com to preview.babylonjs.com on all of your packages (including the GUI, if you load it)

1 Like
<script src="https://preview.babylonjs.com/gui/babylon.gui.js">

Including this line worked like a charm, thanks!