Only getter on InvertY Texture property

Hello !

I’m currently working on a project where I change my assets from .obj to .glb.
I solved most of the annoying cases that can be encountered while doing the transition but there’s till something which I don’t really know how to manage.

The UVs of all my glb seems to be inverted in Y so I tried to solve this by setting my textures to InvertY = false inside the constructor of Texture.
It works however there are also meshes that I create with the MeshBuilder which are fine and get the texture inverted if I set InvertY to false.

The thing is when I call the constructor I’m in a case where I don’t know if it’s a remote model or a procedural and what could have helped me is to set the InvertY property afterward but I get an error when I try to because the property only has a getter.

So is there a way to set it when I want to and avoid to set it inside the constructor or change something on the material where I apply my texture ?

Thanks for helping :slight_smile: !

Pinging our glTF hero @bghgary

May I ask how you are converting from obj to glb? glb (the binary version of glTF) has strict requirements on texture orientation, etc. See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images. It’s probably best to make sure the conversion process does the inversion.

I used the lib from Cesium github. I used the command line obj2gltf and the flag that enables the binary conversion. When I read the manual flags it doesn’t look like there’s something to manage the texure orientation.

It was best for me to use something like this to write a bash script because I needed to convert a thousand of assets.

I think perhaps you can suggest to obj2gltf on GitHub and ask for a flag to do this. Obj doesn’t specify any of this, so it’s unknown whether it should flip or not. FBX2glTF, for example, has flags to flip or not flip the texture coodinates.

Looks like I am having the same issue with obj2gltf three years later. And I do not believe they added a flag to flip the texture coordinates. :slight_smile: Will try to scaleY in babylon to get around it. hopefully wont cause issues.

If it’s a one-shot deal, you can maybe use Blender. If you need to run in a batch, maybe gltf-transform can help after running obj2gltf.

2 Likes