[SOLVED] Measure dimensions of a FBX or glB model

Before I try a harder solution (by use of collision boxes, that gives me contact-positions), I want to know is there is a smarter/easier way to measure World Space dimensions of a FBX or glB model?

Hi @Thomas_Due_Nielsen,

Each model loaded holds an array to all of the mesh instances spawned. Each mesh instance contains an aabb property (pc.BoundingBox) which holds the size of that part of the model in world units.

You can loop through all of the mesh instances and sum up the total bounding box, which will be the size of your model in world units.

The orbit camera script in the model viewer does something similar to find the right distance to get a frame on the target entity. You can check that out.

ok, great - was afraid that all that boundingbox, half-extent etc. ran on ‘relative’ measures alone (could not remember) … will try it (guess I can do a distance from getMin to getMax)

meaning ‘getMin to getMax’ in case I want/need a ‘single unit size’

Check the definition of the pc.BoundingBox class, what you need is the center and halfExtents:

https://developer.playcanvas.com/en/api/pc.BoundingBox.html

For example, to get the size of the mesh instance on the x axis:

var sideX = aabb.halfExtents.x * 2;

got it - works (was already in there; ‘compute’ and ‘getMin’/‘getMax’ were fruitless)

1 Like