rapier.js icon indicating copy to clipboard operation
rapier.js copied to clipboard

JointData.revolute multiple axes

Open EthanHermsey opened this issue 2 years ago • 3 comments

Hey,

I am having trouble with revolute joints. I have tried this with https://cdn.skypack.dev/@dimforge/rapier3d-compat and with webpack and @dimforge/[email protected].

The javascript 3d userguide ánd the joint example shows that you can provide anchor, axis, anchor, axis arguments:

let x = { x: 1.0, y: 0.0, z: 0.0 };
let params = RAPIER.JointParams.revolute({ x: 0.0, y: 0.0, z: 1.0 }, x, { x: 0.0, y: 0.0, z: -3.0 }, x);
let joint = world.createImpulseJoint(params, body1, body2, true);

Those examples both use this RAPIER.JointParams.revolute. However in the docs and in the RAPIER instance I load there's only RAPIER.JointData.revolute. That version of the revolute function only takes 3 arguments; anchor, anchor, axis.

 JointData.revolute = function (anchor1, anchor2, axis) {
        var res = new JointData();
        res.anchor1 = anchor1;
        res.anchor2 = anchor2;
        res.axis = axis;
        res.jointType = JointType.Revolute;
        return res;
    };
    pub fn new(axis: UnitVector<Real>) -> Self {
        let data = GenericJointBuilder::new(JointAxesMask::LOCKED_REVOLUTE_AXES)
            .local_axis1(axis)
            .local_axis2(axis)
            .build();
        Self { data }
    }

I would really like to be able to use specific axes per body. I don't even understand how it would work with just one. Am I doing something wrong, or is this a translation error or something? It should be Axis1, Axis2.

For example, if you connect two cuboid body's with a revolute joint; body1 on the top and body2 on the right side. You'd want to set the y-axis for body1 and the x-axis for body2. Right?

Thanks in advance,

Ethan

EthanHermsey avatar Jun 01 '22 19:06 EthanHermsey