Because there are 12 faces, and i want to detect side

# How to detect intersections of two faces of two bufferGeometryBox?

So, we have 12 faces on 6 sides, each side has 2 faces, thus to find the side by a face index, you need to divide it by 2.

`Math.floor( intersects[0].faceIndex / 2 );`

Oh, sorry. This number from other code. Yes, ofcourse, but my face has faceIndex in range from 30 to 1800

Are you sure that you intersect a box with 12 faces?

Not sure. I set *group* in raycaster

`intersects = raycaster.intersectObject(group, true);`

If i set single mesh object, intersection not working

Pardon, i forgot delete this code .toNonIndexed()

Hi again! I have some trouble ā¦

How to intersect non indexed buffer geometry? I want to detect intersection between two defferent faces of two different non indexed buffergeometry. I set ray from middle of each faces, but raycaster don`t work with non indexed geometry.

I want to see result like this:

Thank you very much!

**my code**

```
var box = new THREE.Mesh(geometry.toNonIndexed(), material);
var raycaster = new THREE.Raycaster();
var intersects = [];
var pos = box.geometry.attributes.position;
var ori = new THREE.Vector3();
var dir = new THREE.Vector3();
var a = new THREE.Vector3(),
b = new THREE.Vector3(),
c = new THREE.Vector3(),
tri = new THREE.Triangle();
var faces = pos.count / 3;
for (let i = 0; i < faces; i++) {
a.fromBufferAttribute(pos, i * 3 + 0);
b.fromBufferAttribute(pos, i * 3 + 1);
c.fromBufferAttribute(pos, i * 3 + 2);
tri.set(a, b, c);
tri.getMidpoint(ori);
tri.getNormal(dir)
// scene.add(new THREE.ArrowHelper(raycaster.ray.direction,
raycaster.ray.origin, 30, 0xff0000));
raycaster.set(ori, dir);
intersects = raycaster.intersectObject(box, true);
if (intersects.length > 0) {
console.log(intersects[0]);
}
}
```

/cc

What does it mean?

Nothing bad. Just the other users can track the issue on other resources.

Oh, ok! I just intersting what mean /cc

Wow, this is a discovery for me. Iām Russian

Hi! I sucessfully set ray from each faces and when intersection detect face , its return flag true. But i have a problem. I cant to return flag false when i delete object, that intersects. My code:

```
box.userData.sides = {
0: false,
1: false,
2: false,
3: false,
4: false,
5: false
}
collision.push(box);
scene.add(box);
checkRaycast();
}
load(0, 0, 0, 'cube', 0, 0, 0);
function checkRaycast() {
var raycaster = new THREE.Raycaster();
var intersects = [];
for (let j = 0; j < collision.length; j++) {
var pos = collision[j].geometry.attributes.position;
var ori = new THREE.Vector3();
var dir = new THREE.Vector3();
var a = new THREE.Vector3(),
b = new THREE.Vector3(),
c = new THREE.Vector3(),
tri = new THREE.Triangle();
var index = collision[j].geometry.index;
var faces = index.count / 3;
scene.updateMatrixWorld()
for (let i = 0; i < faces; i++) {
a.fromBufferAttribute(pos, index.array[i * 3 + 0]);
b.fromBufferAttribute(pos, index.array[i * 3 + 1]);
c.fromBufferAttribute(pos, index.array[i * 3 + 2]);
a.set(a.x + collision[j].position.x, a.y + collision[j].position.y, a.z + collision[j].position.z);
b.set(b.x + collision[j].position.x, b.y + collision[j].position.y, b.z + collision[j].position.z);
c.set(c.x + collision[j].position.x, c.y + collision[j].position.y, c.z + collision[j].position.z);
tri.set(a, b, c);
tri.getMidpoint(ori);
tri.getNormal(dir);
raycaster.set(ori, dir);
intersects = raycaster.intersectObjects(collision, true);
//scene.add(new THREE.ArrowHelper(dir, ori, 500, 0xff0000));
if (intersects.length > 0) {
var intFace = Math.floor(intersects[0].faceIndex / 2);
if (intersects[0].distance > 0 && intersects[0].distance < 0.2) {
intersects[0].object.userData.sides[intFace] = true;
}
} else {
collision[j].userData.sides[0] = false;
collision[j].userData.sides[1] = false;
collision[j].userData.sides[2] = false;
collision[j].userData.sides[3] = false;
collision[j].userData.sides[4] = false;
collision[j].userData.sides[5] = false;
}
}
}
}
```

My project: https://alovert.ru

To add object, please click on object LBM, to delete RBM

I set the flag to false for each side, if the sides do not intersect. But this flag is set for all sides, regardless of whether the sides intersect or not