Unable to get bounding box for 2D element in IOS UIWebView Forge viewer

I have used below code to get bounding box of 2D element.

function find2DBounds( fragList, fragId, dbId, bc ) {
    const mesh = fragList.getVizmesh( fragId );
    const vbr = new Autodesk.Viewing.Private.VertexBufferReader( mesh.geometry );
    vbr.enumGeomsForObject( dbId, bc );
}

function get2DBounds( dbId, model ) {
    const it = model.getData().instanceTree;
    const fragList = model.getFragmentList();

    let bounds = new THREE.Box3();
    let bc = new Autodesk.Viewing.Private.BoundsCallback( bounds );
    const dbId2fragId = model.getData().fragments.dbId2fragId;
    const fragIds = dbId2fragId[dbId];

    if( Array.isArray( fragIds ) ) {
        for( let i = 0; i < fragIds.length; i++ ) {
            find2DBounds( fragList, fragIds[i], dbId, bc );
        }
    } else if( typeof fragIds === 'number' ) {
        find2DBounds( fragList, fragIds, dbId, bc );
    }

    return bc.bounds;
}


var model = this.viewer.model; 
 var modelData = model.getData();
 var itree = modelData.instanceTree;
itree.enumNodeChildren(itree.getRootId(), function (dbId) {   
// Here you go
cosnt bondingBox = get2DBounds( dbId, viewer.model );

}

This code is correctly in browser and getting correct bounding box for 2D elements.
But when I tried to execute this code in browser through IOS, I am not getting bounding box for 2D elements.

Process of use above code through IOS :
– Design a UIWebView in IOS
– Embed html page
– Embed above java script code to into html page
– Get all element ids for 2D sheet.
– Get bounding box for those using above code.

observed that bounding box are infinity for all 2D entities.

Could you please tell me what is wrong with these approach?

55 thoughts on “Unable to get bounding box for 2D element in IOS UIWebView Forge viewer”

Leave a Comment