Hi,
I am trying to detect collision between imported glb object model and box, I have tried with intersectMesh using boundingBox info but it is not working perfectly for car model specially bonnet and trunk areas, I am expecting the collision to be occurred when hitting body of the glb object. So I am using one of available physics engine “cannon” feature physicsImposter.
but while applying Force its giving error Uncaught TypeError: worldPoint.vsub is not a function
tried with Implulse also but same error.
if (pointerRef.current && pointerRef.current.length() > 0) {
const newPosition = eventData.pickInfo?.pickedPoint || new Vector3();
const movementVector = newPosition.subtract(pointerRef.current);
// Apply the movement vector as force to the box's physics impostor
boxBodyRef.current.applyForce(movementVector.scale(50), draggedMeshRef.getAbsolutePosition());
pointerRef.current = newPosition;
}
below is module versions I am using
“@babylonjs/core”: “4.2.1”,
“@babylonjs/gui”: “4.2.1”,
“@babylonjs/loaders”: “4.2.1”,
“cannon”: “^0.6.2”,
“react-babylonjs”: “3.0.31”,