Change Scale of Object to something not arbitrary

Hello everyone,

So im 100% brandnew to this. I just discovered it about two days ago. The whole reason i was looking into babylonjs is to make a app for a website that can change the dimensions of a 3d object via text inputs.

So let me get to the point. If i make an obj of lets say a cube ( it doesnt really matter what it is…just for an example) and import it into babylonjs …and i know when i made it in the other program it was 1x1x1 inches…how do i get babylonjs to “refence” that and change its units to what im considering to be one inch.

Like i said im brand new to all of this even coding. I’m a machinist that uses fusion 360 on a daily basis but this is a new realm for me.

hi there

Every 3D rendering app has internal units that dont pertain to any world measuring units , they are just numbers. Then some of those apps do have options to choose to use real world measuring units but again this is just a representation. For example you can still dictate to the app at what ratio the internal units are applied to the used world measuring units. Simple case is it is just 1:1. But it is possible to use any ratio.

Some apps will specify what they consider their internal unit to convert to when using 1:1. So they might consider 1 unit internally to be 1 meter ( seems to be a common one )

Anyway im not sure how this is applied to interchange formats ( when exporting a model ) using FBX or OBJ or GLTF/GLB. Most exporters have options about how to scale the output. I think some formats do have a internal variable to try read and use in this regard.

When using a real time rendering engine like babylon , what stops you from just labeling your units to anything you like. I mean Its just relative right? Or is there something else that concerns you?

But I know the question then is what is the actual scale of the scene , for example if you loaded several models from different sources.

Here you will find there is no consistency that i know of. You can export a model , import it into another app and export it from that app , then when importing back into the original you find the scale is not the same. ( There might be some consistency in some interchange formats but as mentioned this is also dependent on how the person exported the model )

Most importers have a field where you can choose to apply a normalized scalar value to the imported model if you like. Any model loaded into babylon can be scaled once loaded.


Okay whoa. So are you saying that in the playground for example a unit is just that? a unit?

so if i had a slider bar that i could scrub back and forth to change the length of a cube …say it was the 1x1x1 and wanted it make it 6x1x1 …i would just have to label it as inches on say the UI? assuming its a 1:1 ratio


I do this exact dance all the time so I totally know what you’re talking about. Here are some basics:

When you import an object into BJS it comes in as a Mesh or an array of Meshes. Let’s just say it’s one mesh. And it’s 2x3x4 inches in the real world.

myMesh.getBoundingInfo().boundingBox.extendSizeWorld.scale(2) gives the dimensions in the BJS scene.

Say the dims according to BJS are 7x8x9.

myMesh.scaling.divideInPlace(new BABYLON.Vectors(7,8,9)) scales it down so it’s now has 1x1x1 dimensions in BJS.

myMesh.bakeCurrentTransformIntoVertices() makes it so BJS sees this as a 1x1x1 mesh.

myMesh.scaling = new BABYLON.Vector3(2,3,4) restores it to the correct shape and makes the internal dimensions 2x3x4.

Now when you do myMesh.scaling.y += 2 it’s now 2 units (which you can call inches if you want to) taller.

And this approach works for any shape. It just changes the max dims and scales whatever points are in the middle.

And you can do it with sliders. Or scale boxes. Or both. Or grind the top off using CSGs. BJS is AWESOME for this kind of stuff.

I’m a machine builder and coder so I’m happy you’re here. Fusion 360 makes my head hurt.



Oh- So here’s a part I designed in a playground, exported, and 3d printed yesterday so I would not have to do it in Fusion. Concept to finished part took about 2.5 hours. It’s a snap apart guide for making a wiring harness.



love it! we deal with these all the time at work. the rubber always wears out. I really dig the practical potential here.

Yeah! yeah. this is very much along the lines of what i was looking for. I’m going to fiddle around with this tonight after work. thanks guys for the feedback so far. I may revisit this with more questions later. So i wont be marking it as a solution just yet. Very exciting stuff.

I think the “units” are meant to be in meters, if you are intending to use XR, but otherwise can just be a unit! :smile:

@flex it gives could not find property ’ bakeCurrentTransformIntoVertices() ’

Share a playground. Something silly, no doubt. :stuck_out_tongue_winking_eye:

Hi again all,

So I’ve opened a can of worms with this. becuase i dont know coding yet. i’ve been trying to learn over the past week. I can 3d model all day long but coding is hurting my brain. Here is a perfect example of what im trying to make… a 3d viewer with the ability to manipulate its shape. here But like i said I’m completely new to this. So i guess what im asking…is something like this possible and babylon? Where should i start?

Sounds like you need some javascript and BJS basics.
Maybe start out with CreateBox

And csgs:

Anyone out there know of a good intro to CSGs?

Here’s something I threw together. A real clusterfest but it’s Saturday!

1 Like