Additional Joint Types
Other types of physical joints and constraints:
// Ball-and-socket joint (allows rotation in all directions)
const ballJoint = new BABYLON.PhysicsJoint(
BABYLON.PhysicsJoint.BallAndSocketJoint, {
mainPivot: new BABYLON.Vector3(0, 0, 0),
connectedPivot: new BABYLON.Vector3(0, 2, 0)
}
);
// Distance joint (maintains fixed distance between objects)
const distanceJoint = new BABYLON.PhysicsJoint(
BABYLON.PhysicsJoint.DistanceJoint, {
maxDistance: 5 // Maximum distance constraint
}
);
// Prismatic joint (allows movement along one axis only)
const prismaticJoint = new BABYLON.PhysicsJoint(
BABYLON.PhysicsJoint.PrismaticJoint, {
mainAxis: new BABYLON.Vector3(1, 0, 0), // Movement along X axis
connectedAxis: new BABYLON.Vector3(1, 0, 0)
}
);
// Slider joint with limits
const sliderJoint = new BABYLON.PhysicsJoint(
BABYLON.PhysicsJoint.SliderJoint, {
mainAxis: new BABYLON.Vector3(0, 1, 0),
connectedAxis: new BABYLON.Vector3(0, 1, 0)
}
);
sliderJoint.setLimit(1, 5); // Min and max distance