Hello everyone!
Does anyone know how to calculate thin instances intersection with another static mesh on a scene?
What im trying to do is filling the scene with thin instances of Box (fill whole scene by its boundingbox) and *exclude intersecting instances. By excluding I mean set custom attribute, or just turn alpha to 0 on the instance.

How Im trying to reach that:

const wall = scene.getMeshByName('wall');
let count = 0;
const wallBBOX = wall.getBoundingInfo();
const voxelHalf = voxelSize / 2;
vox.thinInstanceGetWorldMatrices().forEach((matrix, index) => {
const x = matrix.m[12];
const y = matrix.m[13];
const z = matrix.m[14];
const maximum = new BABYLON.Vector3(x + voxelHalf, y + voxelHalf, z + voxelHalf);
const minimum = new BABYLON.Vector3(x - voxelHalf, y - voxelHalf, z - voxelHalf);
const thinBBox = new BABYLON.BoundingInfo(minimum, maximum, matrix);
if (wallBBOX.intersects(thinBBox, false)) {
vox.thinInstanceSetAttributeAt("color", index, [0, 0, 0, 0]);
console.log('intersection');
}
})

Seems like I need to do smth with world matrix so the “instances filling” starts from “scene bounding box minimum”.
The intersected part has alpha 0 on the picute :).