Sprites not rendering when instantiated models are moving

Hello everyone,

I think I might have discovered a bug regarding Sprite rendering. The issue only appears when I try to render a Sprite whilst an instantiated model is moving within the scene.

This is how I am instantiating the model into the scene

const model = await SceneLoader.LoadAssetContainerAsync(`./assets/${path}`, 'my_model.glb', scene);
const modelMesh = model.instantiateModelsToScene('some_name').rootNodes[0]

and this is the code for the Sprite

const spriteManager = new SpriteManager('some_other_name', './assets/explosion_01-min.png', 64, 256, scene);

const sprite = new Sprite(`explosion-${Date.now()}`, spriteManager);
sprite.width = 10;
sprite.height = 10;
sprite.position.y = 0;
sprite.position.x = x;
sprite.position.z = y;
sprite.disposeWhenFinishedAnimating = true;

The weird part is that when instead of an instantiated model, I simply use a box (from MeshBuilder.CreateBox), everything renders as expected.

I’ve also attached some screen grabs to show the issue in action.

Am I doing something wrong? Or is this a bug? The question is, why does it work with a regular mesh but it doesn’t with the instantiated model.

BTW, the fact that the sprite is being animated is irrelevant. It is also happening when I use a sprite without any animations whatsoever.

Model standing still (sprite renders just fine):
still_model

Moving model (sprite fails to render here):
moving_model

Box standing still (sprite renders just fine):
still_box

Moving box (sprite renders just fine):
moving_box

Ohhhh that sounds like a bug, could you create a repro in the playground as I am not able to reproduce it :frowning:

1 Like

I ran into something eerily similar to this. I found that if I hid all of the meshes in the scene (either isVisible = false or setEnabled(false)) that sprites render just fine. Conversely if I had a mesh at the same Y position as the sprite and set alwaysSelectAsActiveMesh = true the sprite always rendered as well.

Our issue was ever so slightly different in that we are using an orthographic camera and it only happened while adjusting the orthoRight (we update all of the ortho directions, but specifically it was the orthoRight affecting the rendering) of the camera.

I’ve tried very hard to repo, but I cannot repro it at all in the playground.

@padronhosnai would be great to see a repro for it ?

Hey guys, sorry for the delayed response.

It turned out that the reason wasn’t about instantiating models. It was being caused by rescaling in every render cycle an instanced plane that had a texture on it. But I’ve managed to solve it by doing the scaling in a shader.

Unfortunately, I don’t think I’ll have time today to set up a PG for it. I’ll try to do it over the weekend and see if the issue comes up as well.

1 Like