BufferGeometry intersection with three-csg-ts - volume calculation

Hello All,
I work with web-ifc, which uses the three.js. At some point, I want to compare two objects. For this purpose, I’m using three-csg-ts library. And the following function:

public static compareTwoGeometryRepresentations(
    geometry1: GeometricalRepresentation,
    geometry2: GeometricalRepresentation
): boolean {
    let mesh1 = CSG.fromMesh(geometry1.geometry);
    let mesh2 = CSG.fromMesh(geometry2.geometry);
    let result = mesh1.intersect(mesh2);
    let volume = GeometryService.getVolume(result.toGeometry(new Matrix4()));
    return (
        // logic
    );
}

Even if I intersect geometries with the same geometry, I get a volume far away from zero. For getVolume I use the implementation presented here:

Can you give me some suggestions on what I am doing wrong or where should I change my thinking ? I’m nooby in the three.js and if you need any relevant information which might be helpful I’ll provide it.

Wojtek

Object one:

{
    "metadata": {
        "version": 4.5,
        "type": "Object",
        "generator": "Object3D.toJSON"
    },
    "geometries": [
        {
            "uuid": "07296F3C-9963-40A6-99F8-CCF7352749CA",
            "type": "BufferGeometry",
            "data": {
                "attributes": {
                    "position": {
                        "isInterleavedBufferAttribute": true,
                        "itemSize": 3,
                        "data": "0E49DBBA-4AB4-4355-9579-3E6593DD39FA",
                        "offset": 0,
                        "normalized": false
                    },
                    "normal": {
                        "isInterleavedBufferAttribute": true,
                        "itemSize": 3,
                        "data": "0E49DBBA-4AB4-4355-9579-3E6593DD39FA",
                        "offset": 3,
                        "normalized": false
                    }
                },
                "index": {
                    "type": "Uint32Array",
                    "array": [
                        3,
                        0,
                        1,
                        1,
                        2,
                        3,
                        8,
                        6,
                        5,
                        6,
                        8,
                        7,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26,
                        27,
                        28,
                        29,
                        30,
                        31,
                        32,
                        33
                    ]
                },
                "interleavedBuffers": {
                    "0E49DBBA-4AB4-4355-9579-3E6593DD39FA": {
                        "uuid": "0E49DBBA-4AB4-4355-9579-3E6593DD39FA",
                        "buffer": "9826E6F3-70D5-4EB3-9601-4DEB6489ACEA",
                        "type": "Float32Array",
                        "stride": 6
                    }
                },
                "arrayBuffers": {
                    "9826E6F3-70D5-4EB3-9601-4DEB6489ACEA": [
                        0,
                        1167663104,
                        1165623296,
                        0,
                        0,
                        1065353216,
                        0,
                        0,
                        1165623296,
                        0,
                        0,
                        1065353216,
                        1167663104,
                        0,
                        1165623296,
                        0,
                        0,
                        1065353216,
                        1167663104,
                        1167663104,
                        1165623296,
                        0,
                        0,
                        1065353216,
                        0,
                        1167663104,
                        1165623296,
                        0,
                        0,
                        1065353216,
                        0,
                        1167663104,
                        0,
                        2147483648,
                        2147483648,
                        3212836864,
                        0,
                        0,
                        0,
                        2147483648,
                        2147483648,
                        3212836864,
                        1167663104,
                        0,
                        0,
                        2147483648,
                        2147483648,
                        3212836864,
                        1167663104,
                        1167663104,
                        0,
                        2147483648,
                        2147483648,
                        3212836864,
                        0,
                        1167663104,
                        0,
                        2147483648,
                        2147483648,
                        3212836864,
                        0,
                        1167663104,
                        0,
                        3212836864,
                        0,
                        0,
                        0,
                        0,
                        1165623296,
                        3212836864,
                        0,
                        0,
                        0,
                        1167663104,
                        1165623296,
                        3212836864,
                        0,
                        0,
                        0,
                        1167663104,
                        0,
                        3212836864,
                        0,
                        0,
                        0,
                        0,
                        0,
                        3212836864,
                        0,
                        0,
                        0,
                        0,
                        1165623296,
                        3212836864,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        3212836864,
                        0,
                        1167663104,
                        0,
                        1165623296,
                        0,
                        3212836864,
                        0,
                        0,
                        0,
                        1165623296,
                        0,
                        3212836864,
                        0,
                        0,
                        0,
                        0,
                        0,
                        3212836864,
                        0,
                        1167663104,
                        0,
                        0,
                        0,
                        3212836864,
                        0,
                        1167663104,
                        0,
                        1165623296,
                        0,
                        3212836864,
                        0,
                        1167663104,
                        0,
                        0,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        1167663104,
                        1165623296,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        0,
                        1165623296,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        0,
                        0,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        1167663104,
                        0,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        1167663104,
                        1165623296,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        1167663104,
                        0,
                        0,
                        1065353216,
                        2147483648,
                        0,
                        1167663104,
                        1165623296,
                        0,
                        1065353216,
                        2147483648,
                        1167663104,
                        1167663104,
                        1165623296,
                        0,
                        1065353216,
                        2147483648,
                        1167663104,
                        1167663104,
                        0,
                        0,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        0,
                        0,
                        1065353216,
                        0,
                        0,
                        1167663104,
                        1165623296,
                        0,
                        1065353216,
                        0
                    ]
                }
            }
        }
    ],
    "materials": [
        {
            "uuid": "C464D1FD-9437-4FCD-8CE6-F3363B605BE6",
            "type": "MeshBasicMaterial",
            "color": 16777215,
            "reflectivity": 1,
            "refractionRatio": 0.98,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680
        }
    ],
    "object": {
        "uuid": "B1752708-1F36-41FE-9938-F9DAB6657DFF",
        "type": "Mesh",
        "layers": 1,
        "matrix": [
            0,
            0,
            0.001,
            0,
            0.001,
            0,
            0,
            0,
            0,
            0.001,
            0,
            0,
            -7.891365415298417,
            0,
            3.3856466512794268,
            1
        ],
        "geometry": "07296F3C-9963-40A6-99F8-CCF7352749CA",
        "material": "C464D1FD-9437-4FCD-8CE6-F3363B605BE6"
    }
}```

It is hard to tell without a live editable example. Most likely I did not understand your question. In any case, if you have the same objects A and B, placed at the same positions, then their intersection will be the same as them (and not with volume 0).

image

Thank you for your answer, and sorry for the improper description of the issue.

The issue while intersecting was caused by improper conversion to BufferGeometry inside the library (web-ifc). The update to the newest version (0.135) resolved the issue, which seemed to look right during uploading objects to scene, but its intersection result provided such the result:
MicrosoftTeams-image (1)