Bug in Babylonjs with sprite/3D Model

Hello,

Since yesterday I have been tackling an issue and I finally found why its happening. So I am importing a 3D model to my scene. The model gets uploaded with textures and works as expected. However when I try to import a sprite alongside the 3D model, the 3D model gets imported without textures. I have tried with multiple models and this is an issue I have been facing. Can someone help me out here?

//Sprite code

           var Lamp = new BABYLON.SpriteManager("Lamp", "RoomTexture/Lamp.png", 200, {
                width: 51,
                height: 98
            }, scene);

            for (var i = 0; i < 5; i++) {
                var spriteLamp = new BABYLON.Sprite("spriteLamp", Lamp);
                spriteLamp.position.x = 890;
                spriteLamp.position.y = -62;
                spriteLamp.position.z = -1100;

                spriteLamp.size = 220;

                spriteLamp.width = 51 * 2.5;
                spriteLamp.height = 98 * 2.5;


                spriteLamp.renderingGroupId = 2;
                Lamp.renderingGroupId = 2;
            }
              //3D Model Code
              scene.onKeyboardObservable.add(async(kbInfo) => {switch (kbInfo.type) { 
              case BABYLON.KeyboardEventTypes.KEYUP:                              
              switch (kbInfo.event.key) {                                                                                            
              case " ": 
              await BABYLON.SceneLoader.ImportMeshAsync(null, "Models/", "model.gltf", scene);
              break;
              }
              break;
              }});
              return scene;
              }

I came across this link from Babylonjs page. There were suppose to be trees with cartoon characters in the scene. Now there are only trees, and if you reduce the number of trees to less than 5, they also disappear with the cartoon characters. There is an issue that began from this week. Can a moderator check this out please:

I will let @Deltakosh have a look at this one, as there has been a big change indeed the last week in the sprite handling.

Ah cool thank you for this, again! :slight_smile:

I’m having a look RIGHT now :slight_smile:

2 Likes

Ok it’s fixed

will be live in a hour or so!

thanks for reporting it!

2 Likes

Hi, unfortunately the bug is still there. The sprites are causing a lot of issues. First, the sprites are only visible if you add them in large number (10 or more sprites). Second, they are causing the issue directly to my imported 3D model by not importing materials/textures. Third, I had created a simple button from Babylon and that got later hidden(but active) because I was adding sprite. The link that I posted above was through Babylon examples page, only trees are visible which are 2000 in number and the spriteManagerPlayer is nowhere to be seen.

Make sure you cleared you cache.

With alpha v32, it seems to work for me: when setting 10 trees in your first link, I do have 10 trees + 2 character sprites.

1 Like

Ah I just cleared it and it worked. I can see the 2 characters. But I still have the issue with missing textures in 3D model when I add sprites. This is still a bug i feel. For the moment I am using plane with imported pngs with alpha channel.

Is it possible for you to make a repro PG of this issue?

If you use Babylon 4.1, does it work?

Here is the link:

The model appears when you press spacebar. Please kindly see why this issue is still there. Thanks!

Here’s a simpler repro with assets from the playground:

https://playground.babylonjs.com/#V4EAZ7#1

Note that once it is bugged, even when commenting the sprite code it remains bugged. You have to reload the PG to make it work.

Here’s a PG with the sprite code commented which does work:

https://playground.babylonjs.com/#V4EAZ7#2

@Deltakosh I think it’s related to the latest changes, however I can’t be sure because the PGs above don’t work in 4.1… It seems the bug happens only when loading gltf/glb files. I tried with .babylon / obj files and couldn’t make it bug.

However, even when loading a .babylon file there’s something strange:

1 Like

Hey thanks for the detailed explanation. I think its the sprite that is definitely causing the issue. It is not the issue with model extension, because so far I have seen that sprite also hides the babylon simple button in the scene. For the time being, I am not using sprites at all.

Also in the https://playground.babylonjs.com/#MUGLWV#2, I can see the textures on the model even though sprites are enabled. The Babylon version is 4.2.0 right?
Sprites somehow ignores .babylon models?

Ok let me check that!

So, the sprites work but are really small:
https://playground.babylonjs.com/#MUGLWV#3

Let me investigate this one: https://playground.babylonjs.com/#V4EAZ7#1

Ok bug found and fixed :slight_smile:
Thanks folks!

2 Likes

Thanks alot for all your help! :slight_smile: