[SOLVED] setLocalScale to same height for different models?

Hi there, I was wondering is it possible to somehow calculate setLocalScale to get +/- same height for all models, I calculate each models bounding box

        x = placement.aabb.halfExtents.x * 2;
        y = placement.aabb.halfExtents.y * 2;
        z = placement.aabb.halfExtents.z * 2;

Some models are like 100,100,100
some like 1,1,1

I was doing something like this:

  if (x > 15 || y > 15 || z > 15) {
    entity.wasTooBig = true;
    if (x > 150 || y > 150 || z > 150) {
    entity.wasTooFreakinBig = true;

and then

  if (placement.wasTooBig == true) {
  placement.setLocalScale(0.05, 0.05, 0.05);
  if (placement.wasTooFreakinBig == true) {
  placement.setLocalScale(0.005, 0.005, 0.005);

I bet theres a better way to do it

Just figured it out, we can mark this as solved, thanks

Can you post your solution here for others to learn from please? :slight_smile:

First calculate a bounding box of a model
Then I take the Z axis of it and add as a new property to the entity

entity.zAxis = z;

Since I do not need the models to be identical height, but so the whole models are visible by the player and is not insanely big as for example model bounding 1000,1000,1000

entity.setLocalScale(1/entity.zAxis, 1/entity.zAxis, 1/entity.zAxis);

Gives me fair results in my case as I can up or down scale models in-game.
As it is not possible to determine height for different models without AI, tested around 100+ models found online and just one matched in-game scaling, it was a toilet… :smile:

And yeah, up down scaling:

placement.setLocalScale(sc.x + (0.01/placement.zAxis), sc.y + (0.01/placement.zAxis), sc.z + (0.01/placement.zAxis));

Using same calculation: Result, scaling ‘looks’ the same speed accros all models since the 0.01 would not work the same for a tiny and for a huge object