user3970726
user3970726

Reputation:

XML3D Bounding boxes

From what I've read in specs each scene element form XML3D has bounding box associated with it. I would like to ask how is the size of bounding boxes calculated? Especially for the <group> and <xml3d> elements - does it take into consideration the sizes of children's bounding boxes? I assume that bounding box size for <mesh> is calculated from mesh vertices positions.

I need this knowledge to tweak camera translation speed.

Upvotes: 1

Views: 66

Answers (1)

csvurt
csvurt

Reputation: 166

As you guessed on <mesh> elements it's calculated from the vertex positions. For <group> elements it's basically calculated as follows:

var bbox = new XML3DBox();
for (var child in children) {
    bbox.extend(child.getWorldBoundingBox());
}

So it recurses until it hits <mesh> elements and the resulting bounding box for each group in the hierarchy is the smallest volume that encloses the bounding boxes of all the child elements, whether they be <groups> or <meshes>. A <group> with no renderable objects (<mesh> or <model>) anywhere in its subtree will return an empty box.

On the <xml3d> element it will return a box that encloses the entire scene.

One thing to remember is that objects marked as invisible (with the visible="false" attribute) won't be included in the bounding box calculations.

Upvotes: 0

Related Questions