SetMaterial just change color of mesh to material color

I add meshes (.babylon files) to scene then materialize them.

Some times are work perfectly as I wish with scaling like these couches:

In some cases after I setMaterial on a mesh it just change color of it just as beds picture:

I changed scale from 0.00001 to 10000
but just show a solid color

the materials set on meshes are pictures like this:
144Bed2.zip (4.0 MB)

I upload couch babylon file, It has 7 part, I change material of each part with diferent scale but still just change to a solid color of material. I want to work like couches, any help would be appreciated.

We would need a repro in the PG, as the problem is most probably in the code and not the models.

Here’s a doc that explains how to host the assets to use them in the PG: Using External Assets - Babylon.js Documentation

So it works for your couch model, but not the bed model?

How complicated is the bed model?

@Evgeni_Popov I’m on it to make PG for it

Yes, it it works for couch and not beds,
What do you mean ‘complicated’? It has 7 parts, if you mean it’s parts

Sorry I thought you said the couch had 7 parts…

I think we’d need to see both models - or at least the model of the bed.

It feels like you’re not addressing the correct part of the bed model. For that we’d need to see some code and probably use Inspector to check.

@eps @Evgeni_Popov
I try to make PG but it just shows me a white screen, so i didn’t saw the result but here is the link:
https://www.babylonjs-playground.com/#CJYX6F#26

It was a lot of code and I try hard to drop extra codes to be concise. Files are exist when I open them in new tab of browser, but they not load in PG. I set Alert functions to get log, you can remove them as your wish.

Have a look at the browser console to see the problems:

@Evgeni_Popov
@eps
I resolve the errors, now you can check my setMaterial function
https://www.babylonjs-playground.com/#CJYX6F#33

As I said bed just painted by color of texture but couch changed it’s texture.

The bed has no uvs:


whereas bag chair has:

How can I set “uv” for it?
With code or manipulating the file?

You should do it in a modeling tool like Blender for eg.

I download them as .babylon files. No way to import in Blender2.82?
I found this article in PG : Calculate UVs for a Custom Mesh | Babylon.js Playground
but how I can find positions of mesh’s vertices to calculate it?
By the way thanks for responses

You can compute uv coordinates by code for very simple shapes like planes or cubes, but for anything more complicated it won’t just be possible.

You can export your mesh from Babylon to a .gltf file then import it in Blender: https://doc.babylonjs.com/extensions/glTFExporter

Thanks a lot, wish best for you due to spending time to resolve other’s problems.