I seem to have a problem with camera collision detection with a mesh loaded as glb.
A glb/gltf mesh might not have indexes, just vertices. I that case the mesh is rendered like OpenGL draw array call. BabylonJS renders the mesh correctly, and it can also be picked, but collisions don’t seem to work.
which expects the indices array. I did some quick testing by adding:
if (indices.length == 0){
for (var i = 0; i < pts.length; i += 3) {
var p1 = pts[i];
var p2 = pts[i+1];
var p3 = pts[i+2];
this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial, hostMesh);
}
}
which seems to activate collisions, but of course is not really correct,
That’s an interesting use case for collisions Would you be able to provide me with a model to test on? will be very helpful in finding a solution for this
I used console logging, for checking collisions, as this camera/triangle combo was not clear enough? without it.
In the original form (the true branch at line 6), the triangle is facing the opposite direction,
so you have to rotate the scene in order to see it. The model used in false part, is posing directly when you start, and it is the one with no collisions behavior. If you look at inspector you see that the second model has 0 faces, which seems to be generally the case when gltf without indices is used.
It is possible that my example itself is broken, in that case let me know, and I will do a better one (outside the sandbox, which I don’t really know)