How to update TileBox size after creation?


Is there a way to update a TiledBox so it continues being tileable after size changes?

let box= MeshBuilder.CreateTiledBox("box", options, scene);

width, height and depth are passed in options at creation, after that, any alteration, causes a stretch of the texture rather of the desired tiling.



Could you share a repro? i am havimg trouble to understand

Sure, see this PG

see how im scaling Y the line before return scene?
tiledBox.scaling.y = 20;

That is whats stretching the TiledBox.
Is there a way to resize the box while the texture of the box is still tileable?

i only manage to do so disposing the box and creating it again from scratch with the new height passed as parameter, otherwise the walls look like the picture above.

This is expected as scaling does not change the uvs of the model unfortunately.

You could try to rely on scaleU and V of your texture to workaround the scaling effect

mmmmm, i understand, but that would resize the texture everywhere.
I want to be able to have different sized walls. It seems i would need to:

a. Dynamically create one texture per different height to apply the correct uvs to them OR…
b. Dispose and recreate the box with the CreateTiledBox that receives height just fine.

Heres what im trying to achieve…

The goal is to create blocks of 1x1x1 that can grow and shrink in Y keeping it tileable look.
I have, lets say, 10 blocks, with different ground sprites, hidden in the scene.
All blocks would have the same texture (atlas) but with different uvs.

Every time i need to place a new cube somewhere, I create an instance of one of those (because they share the same vertex and uvs).

Tiles should be able to have any height, forming walls and stairs and whatnot. Thats the goal.
But its still a 2D map of tiles. Not a 3D one. The size is just a decorative factor to give terrain effect (higher or lower tiles).

Scaling the Y work just fine, but the texture gets stretched as stated before…

Id love something like this to exist:
MeshBuilder.UpdateTiledBox(“box”, {height: 20}, scene)

Any other WA? I will continue exploring this further…

another WA could be to use a custom shader to handle scale per “aera” but I am not sure it would be worth it.