What is the Units that babylon js Take

Hello Guys,

Just have this small doubt regarding the units, let us say I’m measuring distance between two points, I will be getting to end points in Vector format what will be the units which I should consider.

And this so noobish I want to know the Units taken in Babylon js

Very complex issue.

Units are something that basically don’t exist in the 3D world. So what is 1 unit in Babylon. Best answer is, whatever you want it to be.

Let’s see some example in practice. Let’s say that in 3D software you create 3 models.

  1. Model created as 1x2x3cm box.
  2. Model created as 1x2x3m box
  3. Model created as 1x2x3in box

You export this, and import in Babylon. What will happen is that every box will look the same, and every box will be 1x2x3 box (note: unitless).

So basically, you can get the values, but not the units inside the Babylon.

So basically, there is no good solution here. You need to figure out some workaround. For example, what I did in my editor is that I allowed the user to choose the units (basically, even in 3dsMax, if you go to unit settings, you have “display units” and “system units”, indicating that even in 3D software, units are just a convention that you choose. Basically, I created “system units” selection from dropdown menu, as you can see in image bellow.

With that said, FBX format kinda solved this issue, and the FBX file itself is carrying the information about units inside the file itself, and you can parse the file and extract that value. Basically it has something like “unitFactorScale” property inside the file, which shows certain value that represents the unit (100=>meters, 1=>cms, and so on).

Now as Babylon doesn’t support FBX, you need some server side code for this. So you get the FBX file, parse it, extract the value, send it to front, and then convert FBX to GLB, and import in Babylon.

Any other format is completely unitless, and you cannot get the information about the units.

1 Like

@nogalo gets to the heart of the matter with their post, and I’d like to elaborate a bit on it:

On a practical basis, The idea is that you’ll choose a relative size range for your scene and scale your assets to match the world. I like to keep things simple so I don’t have an opportunity to mess things up, so I tend to go with 1unit/1meter scale.

Similarly to 3DSM, blender allows you to specify units and scales in specific measurements as well, but they are just as arbitrary as any other unit space in modeling :sunglasses: