I am creating a process to simplify collisions for complex meshes from imported GLTF models using PhysicsShapeConvexHull
.
As you can see in the debugging, the PhysicsBody
is created correctly. However, the UniversalCamera
and the PhysicsBody
do not collide, and the UniversalCamera
passes through the mesh.
Is collision between a PhysicsShape
and the UniversalCamera
not possible?
//init camera
const camera = new BABYLON.UniversalCamera('camera', new BABYLON.Vector3(0, 7, -5), scene);
camera.speed = 0.3;
camera.applyGravity = true;
camera.checkCollisions = true;
camera.ellipsoid = new BABYLON.Vector3(1, 2, 1);
//simplyfy collision function
if (vertexCount > MAX_VERTEX_COUNT || faceCount > MAX_FACE_COUNT) {
const convexHull = new BABYLON.PhysicsShapeConvexHull(mesh, scene);
console.log('🚀 ~ simplifyCollisions ~ convexHull:', convexHull);
const physicsBody = new BABYLON.PhysicsBody(mesh, BABYLON.PhysicsMotionType.STATIC, false, scene);
physicsBody.shape = convexHull;
physicsBody.setMassProperties({ mass: 0 });
}