Is there a way to check these bounds?

Hello there!
I got these bounds (this white corner thinks) on a template, I want to check if a entitiys position is between the white bounds is there anny optimised way to do this i rather not use a overlaping box or triggers anny idea’s?

Hey, these white bounds usually appear when the entity you clicked has some child entities and they are positioned within the boundary of the white-bound area. You will have to play with localPosition of the entity to set and check the bounds.
Replicating the issue in the public project may help in further sorting out the issue.

1 Like

Hi @Timme_Kingma,

If your entity us using a model or render component, then you can calculate the total volume of the model using the bounding box of each mesh instance.

The model viewer template project (orbit camera) does something similar to get the perfect frame. Here is the code from that script:

OrbitCamera.prototype._buildAabb = function (entity) {
    var i, m, meshInstances = [];

    var renders = entity.findComponents("render");
    for (i = 0; i < renders.length; i++) {
        var render = renders[i];
        for (m = 0; m < render.meshInstances.length; m++) {
            meshInstances.push(render.meshInstances[m]);
        }
    }

    var models = entity.findComponents("model");
    for (i = 0; i < models.length; i++) {
        var model = models[i];
        for (m = 0; m < model.meshInstances.length; m++) {
            meshInstances.push(model.meshInstances[m]);
        }
    }

    for (i = 0; i < meshInstances.length; i++) {
        if (i === 0) {
            this._modelsAabb.copy(meshInstances[i].aabb);
        } else {
            this._modelsAabb.add(meshInstances[i].aabb);
        }
    }
};

As soon as you have the total bounding box, you can use the following method to check if a point is inside it:

https://developer.playcanvas.com/api/pc.BoundingBox.html#containsPoint

3 Likes