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:
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.
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.
@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:
https://playground.babylonjs.com/#MUGLWV#1. There is only the SpriteManager uncommented. As you can see in the inspector, the 0.jpg and textures/grass.png textures are correctly displayed
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?