Frameing all objects into view - isInFrustum / isOccluded not updating as expected

I’m loading a number of objects into the scene and want to frame the camera so that all are in view. In theory I thought I could check this by camera.isInFrustum(mesh) or mesh.isOccluded, assuming that if it is not in frustum, but occluded, it is safe to skip for my check.
However, isOccluded never gets updated, and all my attempts to ignore occlusion and check whether the object is in the frustum even if it is occluded have failes as well.

public frameMeshes = (meshes: BABYLON.AbstractMesh[]) => {
    if (meshes === undefined) {
        meshes = this._scene.meshes;

    let maxLoops: number = 40;
    for (let index = 0; index < maxLoops; index++) {
        let allInFrustrum: boolean = true;
        for (let index = 0; index < meshes.length; index++) {
            const element = meshes[index];
            // check if mesh is either visible in frustum OR is occluded (and thus not visible, but technically "in view")
            allInFrustrum =
                allInFrustrum &&
                (this._camera.isCompletelyInFrustum(element) ||
                `${} ${this._camera.isInFrustum(element)} ${
     // move camera here depending on if everything is in view

Problem: this._camera.isCompletelyInFrustum(element) only shows true for non-occluded meshes, meshes behind this always return false. element.isOccluded always returns false, regardless.

I played with changing occlusionmethods etc but to no avail. Is it something obvious I’m missing?


isOccluded is updated asynchronously (during render time as it uses occlusion queries from the GPU) so unfortunately the value will probably not be available when you ask for it

Ok, so that rules out that (alternatively: could I get the previous’ frames result somewhere?)

Can I then somehow force the camera to “see” meshes even though they are occluded?

If it is only about framing, you can use something like that:

currentScene.activeCamera.useFramingBehavior = true;

var framingBehavior = currentScene.activeCamera.getBehaviorByName("Framing");
framingBehavior.framingTime = 0;
framingBehavior.elevationReturnTime = -1;

var worldExtends = currentScene.getWorldExtends();
currentScene.activeCamera.lowerRadiusLimit = null;
framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);

Ah, that sounds like exactly what I need… will give that a try, thanks!