Hi there,
I have a really weired situation at the moment where my sprites disappear when I add them at a hidden mesh’s position.
Let me explain what am I doing.
I have a .glb model with planes in there. Those planes get replaces by sprites as “hotspots” to get infos about different parts of that model. So traverse through the model to get those specific planes and get the matrix and position of that planes to apply them to the sprites. After applying all that I set the visibility of the planes to false. Now when I click on oh my “hotspots” all the sprites disappear and I can’t figure out why this is happening.
Here some code for you:
var spriteManagerHS = new BABYLON.SpriteManager("hsManager", "/images/icon_hotspot.png", 5, {width: 256, height: 256}, scene);
spriteManagerHS.isPickable = true
var matrix = scene.getMeshByName('__root__').getWorldMatrix();
scene.meshes.forEach(m => {
if (m.name.indexOf('hs_') !== -1 && m.name.indexOf('_sprite') === -1) {
m.position.y = -2;
m.isPickable = false;
m.isVisible = false;
var hs = new BABYLON.Sprite(m.name + '_sprite', spriteManagerHS);
hs.playAnimation(0, 34, true, 50)
hs.size = 2;
hs.isVisible = true;
hs.position = BABYLON.Vector3.TransformCoordinates(m.position, matrix);
hs.isPickable = true;
hotspotArr.push(hs);
}
})
Thank you in advance!