Sign in to follow this  
Pryme8

Project UV from Plane to Mesh, or like process.

Recommended Posts

https://www.babylonjs-playground.com/#NAG06Y#5

Ok, so I have my star shape which has all the vertices labeled, as you can see its UV is all sorts of messy.
What I am trying to do is figure out a simple way to get its UV to match the plane that is the "same size".

I know I can do it mathematically by the points points position in relation to the stars size and manually update the uv buffer.  Just wondering if anyone has a quick and easy trick otherwise.

I was thinking of writing up a "project UV plane"  function, where you pass in a mesh, a plane and a vector3 to signify the projection direction.
So like if the projection axis was Vector3(0,0,1) it would fire rays in this direction (and its inverse) from each of the target meshes vertices and check for a hit on the plane if it hits the plane update that points UV to match the raypicked point's uv.  Is this gibberish or anyone savvy?
 

Share this post


Link to post
Share on other sites

Never mind got it... Unless someone else already has a more robust method.

https://www.babylonjs-playground.com/#NAG06Y#6
https://www.babylonjs-playground.com/#NAG06Y#8 <- Non flat projection.

https://www.babylonjs-playground.com/#NAG06Y#18 <- one with skipTo and stopAt for vertices ID in case you only want to project a section of a mesh.

Share this post


Link to post
Share on other sites

I was kinda thinking about making this a 
BABYLON.Mesh.projectMeshUV method or something.

Could see others having a use for this, but I'm not sure if I have the time to debug and dev it to a full method... so Ill hold off and maybe write a snippet instead. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.