Hi all,
I’m porting a software from Unity to BabylonJS, and I’m currently working on some code that uses Unity’s Bounds class… Babylon’s BoundingInfo seems to be what I am looking for (also thanks to the inglobed boundingBox
field), and the only thing I am lacking is something similar to Unity’s Encapsulate
, which grows the current Bounds to include a given point/bound.
Have I missed the existance of a method that does exactly this for BoundingInfo
by any chance? Or maybe I should use another class?
Of course the underlying implementation of what I am looking for is quite simple (see beneath snippet) and I could (and will) store this code in a custom extension class… But I think it’s a pity that it is not something that’s already available, so I wonder if it could be roadmapped if it is not already the case? (couldn’t find any similar request/discussion)
/// <summary>
/// <para>Grows the Bounds to include the point.</para>
/// </summary>
/// <param name="point"></param>
public void Encapsulate(Vector3 point) => this.SetMinMax(Vector3.Min(this.min, point), Vector3.Max(this.max, point));
/// <summary>
/// <para>Grow the bounds to encapsulate the bounds.</para>
/// </summary>
/// <param name="bounds"></param>
public void Encapsulate(Bounds bounds)
{
this.Encapsulate(bounds.center - bounds.extents);
this.Encapsulate(bounds.center + bounds.extents);
}