# GLTF collision is having weird problem (video included)

I’m getting this weird gltf convex shape collision, where model is reacting to floor goes inside of the floor, probably some mistake in calculating vertices or something? can anyone tell me where am I doing wrong, please?

Already posted this question on a closed solved post but didn’t get any solution so posting once again

I have attached a video of it below and this is the code

``````createMask(Ammo){
let position = {x: 0, y: 70, z: 0},
quaternion = {x: 0, y: 0, z: 0, w: 1},
mass = 1

const scale = 5

//physics

const transform = new Ammo.btTransform();
transform.setIdentity();
transform.setOrigin(new Ammo.btVector3(position.x, position.y, position.z));
transform.setRotation(new Ammo.btQuaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w));

const shape = new Ammo.btConvexHullShape();

//new ammo triangles
let triangle, triangle_mesh = new Ammo.btTriangleMesh;

//declare triangles position vectors
let vectA = new Ammo.btVector3(0, 0, 0);
let vectB = new Ammo.btVector3(0, 0, 0);
let vectC = new Ammo.btVector3(0, 0, 0);

//retrieve vertices positions from object
let verticesPos = head.geometry.getAttribute('position').array;
console.log(verticesPos)
let triangles = [];
for (let i = 0; i < verticesPos.length; i += 3) {
triangles.push({
x: verticesPos[i],
y: verticesPos[i + 1],
z: verticesPos[i + 2]
})
}

//use triangles data to draw ammo shape
for (let i = 0; i < triangles.length - 3; i += 3) {

vectA.setX(triangles[i].x);
vectA.setY(triangles[i].y);
vectA.setZ(triangles[i].z);

vectB.setX(triangles[i + 1].x);
vectB.setY(triangles[i + 1].y);
vectB.setZ(triangles[i + 1].z);

vectC.setX(triangles[i + 2].x);
vectC.setY(triangles[i + 2].y);
vectC.setZ(triangles[i + 2].z);

triangle_mesh.addTriangle(vectA, vectB, vectC, true);
}

Ammo.destroy(vectA);
Ammo.destroy(vectB);
Ammo.destroy(vectC);

shape.setMargin(0.05);
const motionState = new Ammo.btDefaultMotionState(transform);

const localInertia = new Ammo.btVector3(0, 0, 0);
shape.calculateLocalInertia(mass, localInertia);

const rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, motionState, shape, localInertia);

const rBody = new Ammo.btRigidBody(rbInfo);