Jump to content

How to get height and width of a mesh?


Artem
 Share

Recommended Posts

Hmmm, I'm not sure that it is exactly what you want. "scaling.y" is a factor not the final size.

You may want to use player.getBoundingInfo().boundingBox which contains size along x,y and z of the box which wrapps the mesh.

 

Where does 1/60 come from? Is it a value which works for your meshes (ground and player) or works for any other ones?

Link to comment
Share on other sites

Hmmm, I'm not sure that it is exactly what you want. "scaling.y" is a factor not the final size.

You may want to use player.getBoundingInfo().boundingBox which contains size along x,y and z of the box which wrapps the mesh.

 

Where does 1/60 come from? Is it a value which works for your meshes (ground and player) or works for any other ones?

 

Oh, I need to try it then. Thank you for the tip.

 

1/60 is my default world timer (fps), I didn't figure out any other ways yet, so I just use 1/60 everywhere where I calculate stuff.

 

I'm new to all this :)

Link to comment
Share on other sites

var vectorsWorld = player.getBoundingInfo().boundingBox.vectorsWorld; // summits of the bounding boxvar d = vectorsWorld[1].subtract(vectorsWorld[0]).length; // distance between summit 0 and summit 1

Thus you can get the width, the depth and the height of the bounding box, you just need to modify the indices (1 and 0) in the second expression.

 

The values that you will obtain may be the same than 'scaling' BUT it will only be a special case I think.

 

You can replace all your 1/60 by 1/BABYLON.Tools.GetFps()

Link to comment
Share on other sites

  • 3 years later...
  • 1 year later...

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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