Jump to content

InvertUV on ribbon based shapes


Recommended Posts

Hi people,

I just added a new optional parameter, called invertUV (boolean, default false) to every ribbon based shapes : ribbon, tube, lathe, standard and custom extrusion.

var rib = BABYLON.MeshBuilder.CreateRibbon("r", {pathArray: paths, invertUV: true}, scene);

This swaps the U and V coordinates at geometry construction time.

What is this for ?

Imagine you've got two different meshes, say, a tube and a sphere and they share, for performance reasons, the same material/texture. You notice then that the texture is applied on to the tube the wrong way (horizontally, for instance) compared to what you expected, but the right way on the sphere. If you build your texture by rotating the image  for 90°, you will have then a right textured tube but a wrong textured sphere.

So instead of making two different images and to use then two different textures/materials to solve your problem, you can now just invert the UV on the tube and its texture will switched horizontally/vertically.


[EDIT] : 2 tubes, one material/texture, 2 different orientations http://www.babylonjs-playground.com/#G6DG0#8

Link to comment
Share on other sites

I guess I could maybe code this little feature, what is really light in terms of LOC, for any other CreateXXX() methods (not ribbon based) : sphere, cylinder, etc.

And  also I may code some uScale, vScale for the geometry, the same way. Need to study this.

Link to comment
Share on other sites

Hi Jerome!

   Off-topic a bit, but i had a thought about materials on tube INSIDES, and if your new invert parameter would work fine, there, too. 

Then I realized I had never-ever textured the inside of a tube... and I started thinking about side-orientation and mat.backFaceCulling and junk like that.  *shrug*  They are things that need thinking-about sometimes, as you know.  :)


Should we be seeing textures on the outside of 2 tubes that are backside-oriented?

I said to myself... "Self, that is the backFaceCulling on the material set false"...  so I set it true.  It did nothing.

One could ask one's self... what IS the back-side of a back-side-oriented tube?

I came to a conclusion.  I need more coffee.  :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...