Jump to content

Scaling of mesh with unknown position


Recommended Posts

Hey Babylon citizens!

Hope you are all doing well!

I have big scene imported from 3dMAX. I have planes (meshes) in this scene where I dynamically put pictures as textures. And I need to scale my planes (meshes) to fit ratio of the picture before adding picture as a texture. But the problem is this planes are randomly located in scene. So they are just placed in a 3d world with different angles and positions. I did not find a solution in a forum. 

So basically I have plane (mesh) with height and width and I need to adjust height depends on picture ratio. But just  mesh.scaling.x/y/z = ... is not working because this meshes are rotated. Do I need to get vector of left or right edge of my mesh and then apply scaling by this vector? Or is there any other way to achieve my goal?



Link to comment
Share on other sites

Oh thanks RaananW - I think that is the answer to my problem - Scaling happens in local coordinates of the mesh.

I cannot reproduce this problem on playground - because it is a lot of stuff happening on my angular app in order to get this point.

But here what is happening.

Screen Shot 2016-04-27 at 11.30.35 AM.png

This is screenshot from my normal picture on this particular mesh.

And then when I get this mesh and apply mesh.scaling.x = 2  that will give me something like this:

Screen Shot 2016-04-27 at 11.32.54 AM.png

And I was thinking that that is because it scales on Global coordinates.

But if its not, that means that something wrong in my code....

Link to comment
Share on other sites

Hey. Problem resolved.

The problem was in 3dMax object properties. Local scale value was strange in Max, so we did xform reset and all values got back to 100 (looks like this is default value). Now everything scales fine.

Thanks RaananW for the -  "Scaling happens in local coordinates of the mesh"

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...