InstancedMesh: why fully refreshBoundingInfo even without bones

In this code, a forced refresh of bounding info is called in the constructor, which can cause performance issue when creating a lot of instances, since it requires to iterate through all vertices.

A quick blame shows this belong to a skeleton-related fix

But in case bone or morph target does not exist on source mesh, there should be a much faster approuch.

   if (no bones and no morph targets) {
        let bi = this.sourceMesh.getBoundingInfo();
        this.buildBoundingInfo(bi.minimum, bi.maximum);
    } else {
        this.refreshBoundingInfo(true, true);
    }

Also link a similar question here:

cc @bghgary

This optimization seems reasonable to me but let’s get @Deltakosh to weigh in.

I see no problem with it!

@kzhsw Do you want to submit a PR?

2 Likes